documentation.d.ts 3.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486
  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 a string indicating that this uniform must be defined under a #ifdef
  20727. */
  20728. define: string;
  20729. /** @hidden */
  20730. _prioritizeVertex: boolean;
  20731. private _target;
  20732. /** Gets or sets the target of that connection point */
  20733. get target(): NodeMaterialBlockTargets;
  20734. set target(value: NodeMaterialBlockTargets);
  20735. /**
  20736. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20737. */
  20738. get isConnected(): boolean;
  20739. /**
  20740. * Gets a boolean indicating that the current point is connected to an input block
  20741. */
  20742. get isConnectedToInputBlock(): boolean;
  20743. /**
  20744. * Gets a the connected input block (if any)
  20745. */
  20746. get connectInputBlock(): Nullable<InputBlock>;
  20747. /** Get the other side of the connection (if any) */
  20748. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20749. /** Get the block that owns this connection point */
  20750. get ownerBlock(): NodeMaterialBlock;
  20751. /** Get the block connected on the other side of this connection (if any) */
  20752. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20753. /** Get the block connected on the endpoints of this connection (if any) */
  20754. get connectedBlocks(): Array<NodeMaterialBlock>;
  20755. /** Gets the list of connected endpoints */
  20756. get endpoints(): NodeMaterialConnectionPoint[];
  20757. /** Gets a boolean indicating if that output point is connected to at least one input */
  20758. get hasEndpoints(): boolean;
  20759. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20760. get isConnectedInVertexShader(): boolean;
  20761. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20762. get isConnectedInFragmentShader(): boolean;
  20763. /**
  20764. * Creates a block suitable to be used as an input for this input point.
  20765. * If null is returned, a block based on the point type will be created.
  20766. * @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
  20767. */
  20768. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20769. /**
  20770. * Creates a new connection point
  20771. * @param name defines the connection point name
  20772. * @param ownerBlock defines the block hosting this connection point
  20773. * @param direction defines the direction of the connection point
  20774. */
  20775. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20776. /**
  20777. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20778. * @returns the class name
  20779. */
  20780. getClassName(): string;
  20781. /**
  20782. * Gets a boolean indicating if the current point can be connected to another point
  20783. * @param connectionPoint defines the other connection point
  20784. * @returns a boolean
  20785. */
  20786. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20787. /**
  20788. * Gets a number indicating if the current point can be connected to another point
  20789. * @param connectionPoint defines the other connection point
  20790. * @returns a number defining the compatibility state
  20791. */
  20792. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20793. /**
  20794. * Connect this point to another connection point
  20795. * @param connectionPoint defines the other connection point
  20796. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20797. * @returns the current connection point
  20798. */
  20799. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20800. /**
  20801. * Disconnect this point from one of his endpoint
  20802. * @param endpoint defines the other connection point
  20803. * @returns the current connection point
  20804. */
  20805. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20806. /**
  20807. * Serializes this point in a JSON representation
  20808. * @param isInput defines if the connection point is an input (default is true)
  20809. * @returns the serialized point object
  20810. */
  20811. serialize(isInput?: boolean): any;
  20812. /**
  20813. * Release resources
  20814. */
  20815. dispose(): void;
  20816. }
  20817. }
  20818. declare module BABYLON {
  20819. /**
  20820. * Enum used to define the material modes
  20821. */
  20822. export enum NodeMaterialModes {
  20823. /** Regular material */
  20824. Material = 0,
  20825. /** For post process */
  20826. PostProcess = 1,
  20827. /** For particle system */
  20828. Particle = 2,
  20829. /** For procedural texture */
  20830. ProceduralTexture = 3
  20831. }
  20832. }
  20833. declare module BABYLON {
  20834. /**
  20835. * Block used to read a texture from a sampler
  20836. */
  20837. export class TextureBlock extends NodeMaterialBlock {
  20838. private _defineName;
  20839. private _linearDefineName;
  20840. private _gammaDefineName;
  20841. private _tempTextureRead;
  20842. private _samplerName;
  20843. private _transformedUVName;
  20844. private _textureTransformName;
  20845. private _textureInfoName;
  20846. private _mainUVName;
  20847. private _mainUVDefineName;
  20848. private _fragmentOnly;
  20849. /**
  20850. * Gets or sets the texture associated with the node
  20851. */
  20852. texture: Nullable<Texture>;
  20853. /**
  20854. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20855. */
  20856. convertToGammaSpace: boolean;
  20857. /**
  20858. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20859. */
  20860. convertToLinearSpace: boolean;
  20861. /**
  20862. * Create a new TextureBlock
  20863. * @param name defines the block name
  20864. */
  20865. constructor(name: string, fragmentOnly?: boolean);
  20866. /**
  20867. * Gets the current class name
  20868. * @returns the class name
  20869. */
  20870. getClassName(): string;
  20871. /**
  20872. * Gets the uv input component
  20873. */
  20874. get uv(): NodeMaterialConnectionPoint;
  20875. /**
  20876. * Gets the rgba output component
  20877. */
  20878. get rgba(): NodeMaterialConnectionPoint;
  20879. /**
  20880. * Gets the rgb output component
  20881. */
  20882. get rgb(): NodeMaterialConnectionPoint;
  20883. /**
  20884. * Gets the r output component
  20885. */
  20886. get r(): NodeMaterialConnectionPoint;
  20887. /**
  20888. * Gets the g output component
  20889. */
  20890. get g(): NodeMaterialConnectionPoint;
  20891. /**
  20892. * Gets the b output component
  20893. */
  20894. get b(): NodeMaterialConnectionPoint;
  20895. /**
  20896. * Gets the a output component
  20897. */
  20898. get a(): NodeMaterialConnectionPoint;
  20899. get target(): NodeMaterialBlockTargets;
  20900. autoConfigure(material: NodeMaterial): void;
  20901. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  20902. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20903. isReady(): boolean;
  20904. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20905. private get _isMixed();
  20906. private _injectVertexCode;
  20907. private _writeTextureRead;
  20908. private _writeOutput;
  20909. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20910. protected _dumpPropertiesCode(): string;
  20911. serialize(): any;
  20912. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20913. }
  20914. }
  20915. declare module BABYLON {
  20916. /** @hidden */
  20917. export var reflectionFunction: {
  20918. name: string;
  20919. shader: string;
  20920. };
  20921. }
  20922. declare module BABYLON {
  20923. /**
  20924. * Base block used to read a reflection texture from a sampler
  20925. */
  20926. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  20927. /** @hidden */
  20928. _define3DName: string;
  20929. /** @hidden */
  20930. _defineCubicName: string;
  20931. /** @hidden */
  20932. _defineExplicitName: string;
  20933. /** @hidden */
  20934. _defineProjectionName: string;
  20935. /** @hidden */
  20936. _defineLocalCubicName: string;
  20937. /** @hidden */
  20938. _defineSphericalName: string;
  20939. /** @hidden */
  20940. _definePlanarName: string;
  20941. /** @hidden */
  20942. _defineEquirectangularName: string;
  20943. /** @hidden */
  20944. _defineMirroredEquirectangularFixedName: string;
  20945. /** @hidden */
  20946. _defineEquirectangularFixedName: string;
  20947. /** @hidden */
  20948. _defineSkyboxName: string;
  20949. /** @hidden */
  20950. _defineOppositeZ: string;
  20951. /** @hidden */
  20952. _cubeSamplerName: string;
  20953. /** @hidden */
  20954. _2DSamplerName: string;
  20955. protected _positionUVWName: string;
  20956. protected _directionWName: string;
  20957. protected _reflectionVectorName: string;
  20958. /** @hidden */
  20959. _reflectionCoordsName: string;
  20960. /** @hidden */
  20961. _reflectionMatrixName: string;
  20962. protected _reflectionColorName: string;
  20963. /**
  20964. * Gets or sets the texture associated with the node
  20965. */
  20966. texture: Nullable<BaseTexture>;
  20967. /**
  20968. * Create a new ReflectionTextureBaseBlock
  20969. * @param name defines the block name
  20970. */
  20971. constructor(name: string);
  20972. /**
  20973. * Gets the current class name
  20974. * @returns the class name
  20975. */
  20976. getClassName(): string;
  20977. /**
  20978. * Gets the world position input component
  20979. */
  20980. abstract get position(): NodeMaterialConnectionPoint;
  20981. /**
  20982. * Gets the world position input component
  20983. */
  20984. abstract get worldPosition(): NodeMaterialConnectionPoint;
  20985. /**
  20986. * Gets the world normal input component
  20987. */
  20988. abstract get worldNormal(): NodeMaterialConnectionPoint;
  20989. /**
  20990. * Gets the world input component
  20991. */
  20992. abstract get world(): NodeMaterialConnectionPoint;
  20993. /**
  20994. * Gets the camera (or eye) position component
  20995. */
  20996. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  20997. /**
  20998. * Gets the view input component
  20999. */
  21000. abstract get view(): NodeMaterialConnectionPoint;
  21001. protected _getTexture(): Nullable<BaseTexture>;
  21002. autoConfigure(material: NodeMaterial): void;
  21003. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21004. isReady(): boolean;
  21005. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21006. /**
  21007. * Gets the code to inject in the vertex shader
  21008. * @param state current state of the node material building
  21009. * @returns the shader code
  21010. */
  21011. handleVertexSide(state: NodeMaterialBuildState): string;
  21012. /**
  21013. * Handles the inits for the fragment code path
  21014. * @param state node material build state
  21015. */
  21016. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21017. /**
  21018. * Generates the reflection coords code for the fragment code path
  21019. * @param worldNormalVarName name of the world normal variable
  21020. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21021. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21022. * @returns the shader code
  21023. */
  21024. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21025. /**
  21026. * Generates the reflection color code for the fragment code path
  21027. * @param lodVarName name of the lod variable
  21028. * @param swizzleLookupTexture swizzle to use for the final color variable
  21029. * @returns the shader code
  21030. */
  21031. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21032. /**
  21033. * Generates the code corresponding to the connected output points
  21034. * @param state node material build state
  21035. * @param varName name of the variable to output
  21036. * @returns the shader code
  21037. */
  21038. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21039. protected _buildBlock(state: NodeMaterialBuildState): this;
  21040. protected _dumpPropertiesCode(): string;
  21041. serialize(): any;
  21042. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21043. }
  21044. }
  21045. declare module BABYLON {
  21046. /**
  21047. * Defines a connection point to be used for points with a custom object type
  21048. */
  21049. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21050. private _blockType;
  21051. private _blockName;
  21052. private _nameForCheking?;
  21053. /**
  21054. * Creates a new connection point
  21055. * @param name defines the connection point name
  21056. * @param ownerBlock defines the block hosting this connection point
  21057. * @param direction defines the direction of the connection point
  21058. */
  21059. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21060. /**
  21061. * Gets a number indicating if the current point can be connected to another point
  21062. * @param connectionPoint defines the other connection point
  21063. * @returns a number defining the compatibility state
  21064. */
  21065. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21066. /**
  21067. * Creates a block suitable to be used as an input for this input point.
  21068. * If null is returned, a block based on the point type will be created.
  21069. * @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
  21070. */
  21071. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21072. }
  21073. }
  21074. declare module BABYLON {
  21075. /**
  21076. * Enum defining the type of properties that can be edited in the property pages in the NME
  21077. */
  21078. export enum PropertyTypeForEdition {
  21079. /** property is a boolean */
  21080. Boolean = 0,
  21081. /** property is a float */
  21082. Float = 1,
  21083. /** property is a Vector2 */
  21084. Vector2 = 2,
  21085. /** property is a list of values */
  21086. List = 3
  21087. }
  21088. /**
  21089. * Interface that defines an option in a variable of type list
  21090. */
  21091. export interface IEditablePropertyListOption {
  21092. /** label of the option */
  21093. "label": string;
  21094. /** value of the option */
  21095. "value": number;
  21096. }
  21097. /**
  21098. * Interface that defines the options available for an editable property
  21099. */
  21100. export interface IEditablePropertyOption {
  21101. /** min value */
  21102. "min"?: number;
  21103. /** max value */
  21104. "max"?: number;
  21105. /** notifiers: indicates which actions to take when the property is changed */
  21106. "notifiers"?: {
  21107. /** the material should be rebuilt */
  21108. "rebuild"?: boolean;
  21109. /** the preview should be updated */
  21110. "update"?: boolean;
  21111. };
  21112. /** list of the options for a variable of type list */
  21113. "options"?: IEditablePropertyListOption[];
  21114. }
  21115. /**
  21116. * Interface that describes an editable property
  21117. */
  21118. export interface IPropertyDescriptionForEdition {
  21119. /** name of the property */
  21120. "propertyName": string;
  21121. /** display name of the property */
  21122. "displayName": string;
  21123. /** type of the property */
  21124. "type": PropertyTypeForEdition;
  21125. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21126. "groupName": string;
  21127. /** options for the property */
  21128. "options": IEditablePropertyOption;
  21129. }
  21130. /**
  21131. * Decorator that flags a property in a node material block as being editable
  21132. */
  21133. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21134. }
  21135. declare module BABYLON {
  21136. /**
  21137. * Block used to implement the refraction part of the sub surface module of the PBR material
  21138. */
  21139. export class RefractionBlock extends NodeMaterialBlock {
  21140. /** @hidden */
  21141. _define3DName: string;
  21142. /** @hidden */
  21143. _refractionMatrixName: string;
  21144. /** @hidden */
  21145. _defineLODRefractionAlpha: string;
  21146. /** @hidden */
  21147. _defineLinearSpecularRefraction: string;
  21148. /** @hidden */
  21149. _defineOppositeZ: string;
  21150. /** @hidden */
  21151. _cubeSamplerName: string;
  21152. /** @hidden */
  21153. _2DSamplerName: string;
  21154. /** @hidden */
  21155. _vRefractionMicrosurfaceInfosName: string;
  21156. /** @hidden */
  21157. _vRefractionInfosName: string;
  21158. private _scene;
  21159. /**
  21160. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21161. * Materials half opaque for instance using refraction could benefit from this control.
  21162. */
  21163. linkRefractionWithTransparency: boolean;
  21164. /**
  21165. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21166. */
  21167. invertRefractionY: boolean;
  21168. /**
  21169. * Gets or sets the texture associated with the node
  21170. */
  21171. texture: Nullable<BaseTexture>;
  21172. /**
  21173. * Create a new RefractionBlock
  21174. * @param name defines the block name
  21175. */
  21176. constructor(name: string);
  21177. /**
  21178. * Gets the current class name
  21179. * @returns the class name
  21180. */
  21181. getClassName(): string;
  21182. /**
  21183. * Gets the intensity input component
  21184. */
  21185. get intensity(): NodeMaterialConnectionPoint;
  21186. /**
  21187. * Gets the index of refraction input component
  21188. */
  21189. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21190. /**
  21191. * Gets the tint at distance input component
  21192. */
  21193. get tintAtDistance(): NodeMaterialConnectionPoint;
  21194. /**
  21195. * Gets the view input component
  21196. */
  21197. get view(): NodeMaterialConnectionPoint;
  21198. /**
  21199. * Gets the refraction object output component
  21200. */
  21201. get refraction(): NodeMaterialConnectionPoint;
  21202. /**
  21203. * Returns true if the block has a texture
  21204. */
  21205. get hasTexture(): boolean;
  21206. protected _getTexture(): Nullable<BaseTexture>;
  21207. autoConfigure(material: NodeMaterial): void;
  21208. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21209. isReady(): boolean;
  21210. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21211. /**
  21212. * Gets the main code of the block (fragment side)
  21213. * @param state current state of the node material building
  21214. * @returns the shader code
  21215. */
  21216. getCode(state: NodeMaterialBuildState): string;
  21217. protected _buildBlock(state: NodeMaterialBuildState): this;
  21218. protected _dumpPropertiesCode(): string;
  21219. serialize(): any;
  21220. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21221. }
  21222. }
  21223. declare module BABYLON {
  21224. /**
  21225. * Base block used as input for post process
  21226. */
  21227. export class CurrentScreenBlock extends NodeMaterialBlock {
  21228. private _samplerName;
  21229. private _linearDefineName;
  21230. private _gammaDefineName;
  21231. private _mainUVName;
  21232. private _tempTextureRead;
  21233. /**
  21234. * Gets or sets the texture associated with the node
  21235. */
  21236. texture: Nullable<BaseTexture>;
  21237. /**
  21238. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21239. */
  21240. convertToGammaSpace: boolean;
  21241. /**
  21242. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21243. */
  21244. convertToLinearSpace: boolean;
  21245. /**
  21246. * Create a new CurrentScreenBlock
  21247. * @param name defines the block name
  21248. */
  21249. constructor(name: string);
  21250. /**
  21251. * Gets the current class name
  21252. * @returns the class name
  21253. */
  21254. getClassName(): string;
  21255. /**
  21256. * Gets the uv input component
  21257. */
  21258. get uv(): NodeMaterialConnectionPoint;
  21259. /**
  21260. * Gets the rgba output component
  21261. */
  21262. get rgba(): NodeMaterialConnectionPoint;
  21263. /**
  21264. * Gets the rgb output component
  21265. */
  21266. get rgb(): NodeMaterialConnectionPoint;
  21267. /**
  21268. * Gets the r output component
  21269. */
  21270. get r(): NodeMaterialConnectionPoint;
  21271. /**
  21272. * Gets the g output component
  21273. */
  21274. get g(): NodeMaterialConnectionPoint;
  21275. /**
  21276. * Gets the b output component
  21277. */
  21278. get b(): NodeMaterialConnectionPoint;
  21279. /**
  21280. * Gets the a output component
  21281. */
  21282. get a(): NodeMaterialConnectionPoint;
  21283. /**
  21284. * Initialize the block and prepare the context for build
  21285. * @param state defines the state that will be used for the build
  21286. */
  21287. initialize(state: NodeMaterialBuildState): void;
  21288. get target(): NodeMaterialBlockTargets;
  21289. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21290. isReady(): boolean;
  21291. private _injectVertexCode;
  21292. private _writeTextureRead;
  21293. private _writeOutput;
  21294. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21295. serialize(): any;
  21296. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21297. }
  21298. }
  21299. declare module BABYLON {
  21300. /**
  21301. * Base block used for the particle texture
  21302. */
  21303. export class ParticleTextureBlock extends NodeMaterialBlock {
  21304. private _samplerName;
  21305. private _linearDefineName;
  21306. private _gammaDefineName;
  21307. private _tempTextureRead;
  21308. /**
  21309. * Gets or sets the texture associated with the node
  21310. */
  21311. texture: Nullable<BaseTexture>;
  21312. /**
  21313. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21314. */
  21315. convertToGammaSpace: boolean;
  21316. /**
  21317. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21318. */
  21319. convertToLinearSpace: boolean;
  21320. /**
  21321. * Create a new ParticleTextureBlock
  21322. * @param name defines the block name
  21323. */
  21324. constructor(name: string);
  21325. /**
  21326. * Gets the current class name
  21327. * @returns the class name
  21328. */
  21329. getClassName(): string;
  21330. /**
  21331. * Gets the uv input component
  21332. */
  21333. get uv(): NodeMaterialConnectionPoint;
  21334. /**
  21335. * Gets the rgba output component
  21336. */
  21337. get rgba(): NodeMaterialConnectionPoint;
  21338. /**
  21339. * Gets the rgb output component
  21340. */
  21341. get rgb(): NodeMaterialConnectionPoint;
  21342. /**
  21343. * Gets the r output component
  21344. */
  21345. get r(): NodeMaterialConnectionPoint;
  21346. /**
  21347. * Gets the g output component
  21348. */
  21349. get g(): NodeMaterialConnectionPoint;
  21350. /**
  21351. * Gets the b output component
  21352. */
  21353. get b(): NodeMaterialConnectionPoint;
  21354. /**
  21355. * Gets the a output component
  21356. */
  21357. get a(): NodeMaterialConnectionPoint;
  21358. /**
  21359. * Initialize the block and prepare the context for build
  21360. * @param state defines the state that will be used for the build
  21361. */
  21362. initialize(state: NodeMaterialBuildState): void;
  21363. autoConfigure(material: NodeMaterial): void;
  21364. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21365. isReady(): boolean;
  21366. private _writeOutput;
  21367. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21368. serialize(): any;
  21369. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21370. }
  21371. }
  21372. declare module BABYLON {
  21373. /**
  21374. * Class used to store shared data between 2 NodeMaterialBuildState
  21375. */
  21376. export class NodeMaterialBuildStateSharedData {
  21377. /**
  21378. * Gets the list of emitted varyings
  21379. */
  21380. temps: string[];
  21381. /**
  21382. * Gets the list of emitted varyings
  21383. */
  21384. varyings: string[];
  21385. /**
  21386. * Gets the varying declaration string
  21387. */
  21388. varyingDeclaration: string;
  21389. /**
  21390. * Input blocks
  21391. */
  21392. inputBlocks: InputBlock[];
  21393. /**
  21394. * Input blocks
  21395. */
  21396. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21397. /**
  21398. * Bindable blocks (Blocks that need to set data to the effect)
  21399. */
  21400. bindableBlocks: NodeMaterialBlock[];
  21401. /**
  21402. * List of blocks that can provide a compilation fallback
  21403. */
  21404. blocksWithFallbacks: NodeMaterialBlock[];
  21405. /**
  21406. * List of blocks that can provide a define update
  21407. */
  21408. blocksWithDefines: NodeMaterialBlock[];
  21409. /**
  21410. * List of blocks that can provide a repeatable content
  21411. */
  21412. repeatableContentBlocks: NodeMaterialBlock[];
  21413. /**
  21414. * List of blocks that can provide a dynamic list of uniforms
  21415. */
  21416. dynamicUniformBlocks: NodeMaterialBlock[];
  21417. /**
  21418. * List of blocks that can block the isReady function for the material
  21419. */
  21420. blockingBlocks: NodeMaterialBlock[];
  21421. /**
  21422. * Gets the list of animated inputs
  21423. */
  21424. animatedInputs: InputBlock[];
  21425. /**
  21426. * Build Id used to avoid multiple recompilations
  21427. */
  21428. buildId: number;
  21429. /** List of emitted variables */
  21430. variableNames: {
  21431. [key: string]: number;
  21432. };
  21433. /** List of emitted defines */
  21434. defineNames: {
  21435. [key: string]: number;
  21436. };
  21437. /** Should emit comments? */
  21438. emitComments: boolean;
  21439. /** Emit build activity */
  21440. verbose: boolean;
  21441. /** Gets or sets the hosting scene */
  21442. scene: Scene;
  21443. /**
  21444. * Gets the compilation hints emitted at compilation time
  21445. */
  21446. hints: {
  21447. needWorldViewMatrix: boolean;
  21448. needWorldViewProjectionMatrix: boolean;
  21449. needAlphaBlending: boolean;
  21450. needAlphaTesting: boolean;
  21451. };
  21452. /**
  21453. * List of compilation checks
  21454. */
  21455. checks: {
  21456. emitVertex: boolean;
  21457. emitFragment: boolean;
  21458. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21459. };
  21460. /**
  21461. * Is vertex program allowed to be empty?
  21462. */
  21463. allowEmptyVertexProgram: boolean;
  21464. /** Creates a new shared data */
  21465. constructor();
  21466. /**
  21467. * Emits console errors and exceptions if there is a failing check
  21468. */
  21469. emitErrors(): void;
  21470. }
  21471. }
  21472. declare module BABYLON {
  21473. /**
  21474. * Class used to store node based material build state
  21475. */
  21476. export class NodeMaterialBuildState {
  21477. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21478. supportUniformBuffers: boolean;
  21479. /**
  21480. * Gets the list of emitted attributes
  21481. */
  21482. attributes: string[];
  21483. /**
  21484. * Gets the list of emitted uniforms
  21485. */
  21486. uniforms: string[];
  21487. /**
  21488. * Gets the list of emitted constants
  21489. */
  21490. constants: string[];
  21491. /**
  21492. * Gets the list of emitted samplers
  21493. */
  21494. samplers: string[];
  21495. /**
  21496. * Gets the list of emitted functions
  21497. */
  21498. functions: {
  21499. [key: string]: string;
  21500. };
  21501. /**
  21502. * Gets the list of emitted extensions
  21503. */
  21504. extensions: {
  21505. [key: string]: string;
  21506. };
  21507. /**
  21508. * Gets the target of the compilation state
  21509. */
  21510. target: NodeMaterialBlockTargets;
  21511. /**
  21512. * Gets the list of emitted counters
  21513. */
  21514. counters: {
  21515. [key: string]: number;
  21516. };
  21517. /**
  21518. * Shared data between multiple NodeMaterialBuildState instances
  21519. */
  21520. sharedData: NodeMaterialBuildStateSharedData;
  21521. /** @hidden */
  21522. _vertexState: NodeMaterialBuildState;
  21523. /** @hidden */
  21524. _attributeDeclaration: string;
  21525. /** @hidden */
  21526. _uniformDeclaration: string;
  21527. /** @hidden */
  21528. _constantDeclaration: string;
  21529. /** @hidden */
  21530. _samplerDeclaration: string;
  21531. /** @hidden */
  21532. _varyingTransfer: string;
  21533. /** @hidden */
  21534. _injectAtEnd: string;
  21535. private _repeatableContentAnchorIndex;
  21536. /** @hidden */
  21537. _builtCompilationString: string;
  21538. /**
  21539. * Gets the emitted compilation strings
  21540. */
  21541. compilationString: string;
  21542. /**
  21543. * Finalize the compilation strings
  21544. * @param state defines the current compilation state
  21545. */
  21546. finalize(state: NodeMaterialBuildState): void;
  21547. /** @hidden */
  21548. get _repeatableContentAnchor(): string;
  21549. /** @hidden */
  21550. _getFreeVariableName(prefix: string): string;
  21551. /** @hidden */
  21552. _getFreeDefineName(prefix: string): string;
  21553. /** @hidden */
  21554. _excludeVariableName(name: string): void;
  21555. /** @hidden */
  21556. _emit2DSampler(name: string): void;
  21557. /** @hidden */
  21558. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21559. /** @hidden */
  21560. _emitExtension(name: string, extension: string, define?: string): void;
  21561. /** @hidden */
  21562. _emitFunction(name: string, code: string, comments: string): void;
  21563. /** @hidden */
  21564. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21565. replaceStrings?: {
  21566. search: RegExp;
  21567. replace: string;
  21568. }[];
  21569. repeatKey?: string;
  21570. }): string;
  21571. /** @hidden */
  21572. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21573. repeatKey?: string;
  21574. removeAttributes?: boolean;
  21575. removeUniforms?: boolean;
  21576. removeVaryings?: boolean;
  21577. removeIfDef?: boolean;
  21578. replaceStrings?: {
  21579. search: RegExp;
  21580. replace: string;
  21581. }[];
  21582. }, storeKey?: string): void;
  21583. /** @hidden */
  21584. _registerTempVariable(name: string): boolean;
  21585. /** @hidden */
  21586. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21587. /** @hidden */
  21588. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21589. /** @hidden */
  21590. _emitFloat(value: number): string;
  21591. }
  21592. }
  21593. declare module BABYLON {
  21594. /**
  21595. * Helper class used to generate session unique ID
  21596. */
  21597. export class UniqueIdGenerator {
  21598. private static _UniqueIdCounter;
  21599. /**
  21600. * Gets an unique (relatively to the current scene) Id
  21601. */
  21602. static get UniqueId(): number;
  21603. }
  21604. }
  21605. declare module BABYLON {
  21606. /**
  21607. * Defines a block that can be used inside a node based material
  21608. */
  21609. export class NodeMaterialBlock {
  21610. private _buildId;
  21611. private _buildTarget;
  21612. private _target;
  21613. private _isFinalMerger;
  21614. private _isInput;
  21615. private _name;
  21616. protected _isUnique: boolean;
  21617. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21618. inputsAreExclusive: boolean;
  21619. /** @hidden */
  21620. _codeVariableName: string;
  21621. /** @hidden */
  21622. _inputs: NodeMaterialConnectionPoint[];
  21623. /** @hidden */
  21624. _outputs: NodeMaterialConnectionPoint[];
  21625. /** @hidden */
  21626. _preparationId: number;
  21627. /**
  21628. * Gets the name of the block
  21629. */
  21630. get name(): string;
  21631. /**
  21632. * Sets the name of the block. Will check if the name is valid.
  21633. */
  21634. set name(newName: string);
  21635. /**
  21636. * Gets or sets the unique id of the node
  21637. */
  21638. uniqueId: number;
  21639. /**
  21640. * Gets or sets the comments associated with this block
  21641. */
  21642. comments: string;
  21643. /**
  21644. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21645. */
  21646. get isUnique(): boolean;
  21647. /**
  21648. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21649. */
  21650. get isFinalMerger(): boolean;
  21651. /**
  21652. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21653. */
  21654. get isInput(): boolean;
  21655. /**
  21656. * Gets or sets the build Id
  21657. */
  21658. get buildId(): number;
  21659. set buildId(value: number);
  21660. /**
  21661. * Gets or sets the target of the block
  21662. */
  21663. get target(): NodeMaterialBlockTargets;
  21664. set target(value: NodeMaterialBlockTargets);
  21665. /**
  21666. * Gets the list of input points
  21667. */
  21668. get inputs(): NodeMaterialConnectionPoint[];
  21669. /** Gets the list of output points */
  21670. get outputs(): NodeMaterialConnectionPoint[];
  21671. /**
  21672. * Find an input by its name
  21673. * @param name defines the name of the input to look for
  21674. * @returns the input or null if not found
  21675. */
  21676. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21677. /**
  21678. * Find an output by its name
  21679. * @param name defines the name of the outputto look for
  21680. * @returns the output or null if not found
  21681. */
  21682. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21683. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  21684. visibleInInspector: boolean;
  21685. /**
  21686. * Creates a new NodeMaterialBlock
  21687. * @param name defines the block name
  21688. * @param target defines the target of that block (Vertex by default)
  21689. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21690. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21691. */
  21692. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21693. /**
  21694. * Initialize the block and prepare the context for build
  21695. * @param state defines the state that will be used for the build
  21696. */
  21697. initialize(state: NodeMaterialBuildState): void;
  21698. /**
  21699. * Bind data to effect. Will only be called for blocks with isBindable === true
  21700. * @param effect defines the effect to bind data to
  21701. * @param nodeMaterial defines the hosting NodeMaterial
  21702. * @param mesh defines the mesh that will be rendered
  21703. * @param subMesh defines the submesh that will be rendered
  21704. */
  21705. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21706. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21707. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21708. protected _writeFloat(value: number): string;
  21709. /**
  21710. * Gets the current class name e.g. "NodeMaterialBlock"
  21711. * @returns the class name
  21712. */
  21713. getClassName(): string;
  21714. /**
  21715. * Register a new input. Must be called inside a block constructor
  21716. * @param name defines the connection point name
  21717. * @param type defines the connection point type
  21718. * @param isOptional defines a boolean indicating that this input can be omitted
  21719. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21720. * @param point an already created connection point. If not provided, create a new one
  21721. * @returns the current block
  21722. */
  21723. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21724. /**
  21725. * Register a new output. Must be called inside a block constructor
  21726. * @param name defines the connection point name
  21727. * @param type defines the connection point type
  21728. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21729. * @param point an already created connection point. If not provided, create a new one
  21730. * @returns the current block
  21731. */
  21732. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21733. /**
  21734. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21735. * @param forOutput defines an optional connection point to check compatibility with
  21736. * @returns the first available input or null
  21737. */
  21738. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21739. /**
  21740. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21741. * @param forBlock defines an optional block to check compatibility with
  21742. * @returns the first available input or null
  21743. */
  21744. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21745. /**
  21746. * Gets the sibling of the given output
  21747. * @param current defines the current output
  21748. * @returns the next output in the list or null
  21749. */
  21750. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21751. /**
  21752. * Connect current block with another block
  21753. * @param other defines the block to connect with
  21754. * @param options define the various options to help pick the right connections
  21755. * @returns the current block
  21756. */
  21757. connectTo(other: NodeMaterialBlock, options?: {
  21758. input?: string;
  21759. output?: string;
  21760. outputSwizzle?: string;
  21761. }): this | undefined;
  21762. protected _buildBlock(state: NodeMaterialBuildState): void;
  21763. /**
  21764. * Add uniforms, samplers and uniform buffers at compilation time
  21765. * @param state defines the state to update
  21766. * @param nodeMaterial defines the node material requesting the update
  21767. * @param defines defines the material defines to update
  21768. * @param uniformBuffers defines the list of uniform buffer names
  21769. */
  21770. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21771. /**
  21772. * Add potential fallbacks if shader compilation fails
  21773. * @param mesh defines the mesh to be rendered
  21774. * @param fallbacks defines the current prioritized list of fallbacks
  21775. */
  21776. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21777. /**
  21778. * Initialize defines for shader compilation
  21779. * @param mesh defines the mesh to be rendered
  21780. * @param nodeMaterial defines the node material requesting the update
  21781. * @param defines defines the material defines to update
  21782. * @param useInstances specifies that instances should be used
  21783. */
  21784. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21785. /**
  21786. * Update defines for shader compilation
  21787. * @param mesh defines the mesh to be rendered
  21788. * @param nodeMaterial defines the node material requesting the update
  21789. * @param defines defines the material defines to update
  21790. * @param useInstances specifies that instances should be used
  21791. * @param subMesh defines which submesh to render
  21792. */
  21793. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21794. /**
  21795. * Lets the block try to connect some inputs automatically
  21796. * @param material defines the hosting NodeMaterial
  21797. */
  21798. autoConfigure(material: NodeMaterial): void;
  21799. /**
  21800. * Function called when a block is declared as repeatable content generator
  21801. * @param vertexShaderState defines the current compilation state for the vertex shader
  21802. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21803. * @param mesh defines the mesh to be rendered
  21804. * @param defines defines the material defines to update
  21805. */
  21806. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21807. /**
  21808. * Checks if the block is ready
  21809. * @param mesh defines the mesh to be rendered
  21810. * @param nodeMaterial defines the node material requesting the update
  21811. * @param defines defines the material defines to update
  21812. * @param useInstances specifies that instances should be used
  21813. * @returns true if the block is ready
  21814. */
  21815. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21816. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21817. private _processBuild;
  21818. /**
  21819. * Validates the new name for the block node.
  21820. * @param newName the new name to be given to the node.
  21821. * @returns false if the name is a reserve word, else true.
  21822. */
  21823. validateBlockName(newName: string): boolean;
  21824. /**
  21825. * Compile the current node and generate the shader code
  21826. * @param state defines the current compilation state (uniforms, samplers, current string)
  21827. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21828. * @returns true if already built
  21829. */
  21830. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21831. protected _inputRename(name: string): string;
  21832. protected _outputRename(name: string): string;
  21833. protected _dumpPropertiesCode(): string;
  21834. /** @hidden */
  21835. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21836. /** @hidden */
  21837. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21838. /**
  21839. * Clone the current block to a new identical block
  21840. * @param scene defines the hosting scene
  21841. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21842. * @returns a copy of the current block
  21843. */
  21844. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21845. /**
  21846. * Serializes this block in a JSON representation
  21847. * @returns the serialized block object
  21848. */
  21849. serialize(): any;
  21850. /** @hidden */
  21851. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21852. private _deserializePortDisplayNamesAndExposedOnFrame;
  21853. /**
  21854. * Release resources
  21855. */
  21856. dispose(): void;
  21857. }
  21858. }
  21859. declare module BABYLON {
  21860. /**
  21861. * Base class of materials working in push mode in babylon JS
  21862. * @hidden
  21863. */
  21864. export class PushMaterial extends Material {
  21865. protected _activeEffect: Effect;
  21866. protected _normalMatrix: Matrix;
  21867. constructor(name: string, scene: Scene);
  21868. getEffect(): Effect;
  21869. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21870. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21871. /**
  21872. * Binds the given world matrix to the active effect
  21873. *
  21874. * @param world the matrix to bind
  21875. */
  21876. bindOnlyWorldMatrix(world: Matrix): void;
  21877. /**
  21878. * Binds the given normal matrix to the active effect
  21879. *
  21880. * @param normalMatrix the matrix to bind
  21881. */
  21882. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21883. bind(world: Matrix, mesh?: Mesh): void;
  21884. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21885. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21886. }
  21887. }
  21888. declare module BABYLON {
  21889. /**
  21890. * Root class for all node material optimizers
  21891. */
  21892. export class NodeMaterialOptimizer {
  21893. /**
  21894. * Function used to optimize a NodeMaterial graph
  21895. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  21896. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  21897. */
  21898. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  21899. }
  21900. }
  21901. declare module BABYLON {
  21902. /**
  21903. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  21904. */
  21905. export class TransformBlock extends NodeMaterialBlock {
  21906. /**
  21907. * Defines the value to use to complement W value to transform it to a Vector4
  21908. */
  21909. complementW: number;
  21910. /**
  21911. * Defines the value to use to complement z value to transform it to a Vector4
  21912. */
  21913. complementZ: number;
  21914. /**
  21915. * Creates a new TransformBlock
  21916. * @param name defines the block name
  21917. */
  21918. constructor(name: string);
  21919. /**
  21920. * Gets the current class name
  21921. * @returns the class name
  21922. */
  21923. getClassName(): string;
  21924. /**
  21925. * Gets the vector input
  21926. */
  21927. get vector(): NodeMaterialConnectionPoint;
  21928. /**
  21929. * Gets the output component
  21930. */
  21931. get output(): NodeMaterialConnectionPoint;
  21932. /**
  21933. * Gets the xyz output component
  21934. */
  21935. get xyz(): NodeMaterialConnectionPoint;
  21936. /**
  21937. * Gets the matrix transform input
  21938. */
  21939. get transform(): NodeMaterialConnectionPoint;
  21940. protected _buildBlock(state: NodeMaterialBuildState): this;
  21941. /**
  21942. * Update defines for shader compilation
  21943. * @param mesh defines the mesh to be rendered
  21944. * @param nodeMaterial defines the node material requesting the update
  21945. * @param defines defines the material defines to update
  21946. * @param useInstances specifies that instances should be used
  21947. * @param subMesh defines which submesh to render
  21948. */
  21949. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21950. serialize(): any;
  21951. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21952. protected _dumpPropertiesCode(): string;
  21953. }
  21954. }
  21955. declare module BABYLON {
  21956. /**
  21957. * Block used to output the vertex position
  21958. */
  21959. export class VertexOutputBlock extends NodeMaterialBlock {
  21960. /**
  21961. * Creates a new VertexOutputBlock
  21962. * @param name defines the block name
  21963. */
  21964. constructor(name: string);
  21965. /**
  21966. * Gets the current class name
  21967. * @returns the class name
  21968. */
  21969. getClassName(): string;
  21970. /**
  21971. * Gets the vector input component
  21972. */
  21973. get vector(): NodeMaterialConnectionPoint;
  21974. protected _buildBlock(state: NodeMaterialBuildState): this;
  21975. }
  21976. }
  21977. declare module BABYLON {
  21978. /**
  21979. * Block used to output the final color
  21980. */
  21981. export class FragmentOutputBlock extends NodeMaterialBlock {
  21982. /**
  21983. * Create a new FragmentOutputBlock
  21984. * @param name defines the block name
  21985. */
  21986. constructor(name: string);
  21987. /**
  21988. * Gets the current class name
  21989. * @returns the class name
  21990. */
  21991. getClassName(): string;
  21992. /**
  21993. * Gets the rgba input component
  21994. */
  21995. get rgba(): NodeMaterialConnectionPoint;
  21996. /**
  21997. * Gets the rgb input component
  21998. */
  21999. get rgb(): NodeMaterialConnectionPoint;
  22000. /**
  22001. * Gets the a input component
  22002. */
  22003. get a(): NodeMaterialConnectionPoint;
  22004. protected _buildBlock(state: NodeMaterialBuildState): this;
  22005. }
  22006. }
  22007. declare module BABYLON {
  22008. /**
  22009. * Block used for the particle ramp gradient section
  22010. */
  22011. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22012. /**
  22013. * Create a new ParticleRampGradientBlock
  22014. * @param name defines the block name
  22015. */
  22016. constructor(name: string);
  22017. /**
  22018. * Gets the current class name
  22019. * @returns the class name
  22020. */
  22021. getClassName(): string;
  22022. /**
  22023. * Gets the color input component
  22024. */
  22025. get color(): NodeMaterialConnectionPoint;
  22026. /**
  22027. * Gets the rampColor output component
  22028. */
  22029. get rampColor(): NodeMaterialConnectionPoint;
  22030. /**
  22031. * Initialize the block and prepare the context for build
  22032. * @param state defines the state that will be used for the build
  22033. */
  22034. initialize(state: NodeMaterialBuildState): void;
  22035. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22036. }
  22037. }
  22038. declare module BABYLON {
  22039. /**
  22040. * Block used for the particle blend multiply section
  22041. */
  22042. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22043. /**
  22044. * Create a new ParticleBlendMultiplyBlock
  22045. * @param name defines the block name
  22046. */
  22047. constructor(name: string);
  22048. /**
  22049. * Gets the current class name
  22050. * @returns the class name
  22051. */
  22052. getClassName(): string;
  22053. /**
  22054. * Gets the color input component
  22055. */
  22056. get color(): NodeMaterialConnectionPoint;
  22057. /**
  22058. * Gets the alphaTexture input component
  22059. */
  22060. get alphaTexture(): NodeMaterialConnectionPoint;
  22061. /**
  22062. * Gets the alphaColor input component
  22063. */
  22064. get alphaColor(): NodeMaterialConnectionPoint;
  22065. /**
  22066. * Gets the blendColor output component
  22067. */
  22068. get blendColor(): NodeMaterialConnectionPoint;
  22069. /**
  22070. * Initialize the block and prepare the context for build
  22071. * @param state defines the state that will be used for the build
  22072. */
  22073. initialize(state: NodeMaterialBuildState): void;
  22074. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22075. }
  22076. }
  22077. declare module BABYLON {
  22078. /**
  22079. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22080. */
  22081. export class VectorMergerBlock extends NodeMaterialBlock {
  22082. /**
  22083. * Create a new VectorMergerBlock
  22084. * @param name defines the block name
  22085. */
  22086. constructor(name: string);
  22087. /**
  22088. * Gets the current class name
  22089. * @returns the class name
  22090. */
  22091. getClassName(): string;
  22092. /**
  22093. * Gets the xyz component (input)
  22094. */
  22095. get xyzIn(): NodeMaterialConnectionPoint;
  22096. /**
  22097. * Gets the xy component (input)
  22098. */
  22099. get xyIn(): NodeMaterialConnectionPoint;
  22100. /**
  22101. * Gets the x component (input)
  22102. */
  22103. get x(): NodeMaterialConnectionPoint;
  22104. /**
  22105. * Gets the y component (input)
  22106. */
  22107. get y(): NodeMaterialConnectionPoint;
  22108. /**
  22109. * Gets the z component (input)
  22110. */
  22111. get z(): NodeMaterialConnectionPoint;
  22112. /**
  22113. * Gets the w component (input)
  22114. */
  22115. get w(): NodeMaterialConnectionPoint;
  22116. /**
  22117. * Gets the xyzw component (output)
  22118. */
  22119. get xyzw(): NodeMaterialConnectionPoint;
  22120. /**
  22121. * Gets the xyz component (output)
  22122. */
  22123. get xyzOut(): NodeMaterialConnectionPoint;
  22124. /**
  22125. * Gets the xy component (output)
  22126. */
  22127. get xyOut(): NodeMaterialConnectionPoint;
  22128. /**
  22129. * Gets the xy component (output)
  22130. * @deprecated Please use xyOut instead.
  22131. */
  22132. get xy(): NodeMaterialConnectionPoint;
  22133. /**
  22134. * Gets the xyz component (output)
  22135. * @deprecated Please use xyzOut instead.
  22136. */
  22137. get xyz(): NodeMaterialConnectionPoint;
  22138. protected _buildBlock(state: NodeMaterialBuildState): this;
  22139. }
  22140. }
  22141. declare module BABYLON {
  22142. /**
  22143. * Block used to remap a float from a range to a new one
  22144. */
  22145. export class RemapBlock extends NodeMaterialBlock {
  22146. /**
  22147. * Gets or sets the source range
  22148. */
  22149. sourceRange: Vector2;
  22150. /**
  22151. * Gets or sets the target range
  22152. */
  22153. targetRange: Vector2;
  22154. /**
  22155. * Creates a new RemapBlock
  22156. * @param name defines the block name
  22157. */
  22158. constructor(name: string);
  22159. /**
  22160. * Gets the current class name
  22161. * @returns the class name
  22162. */
  22163. getClassName(): string;
  22164. /**
  22165. * Gets the input component
  22166. */
  22167. get input(): NodeMaterialConnectionPoint;
  22168. /**
  22169. * Gets the source min input component
  22170. */
  22171. get sourceMin(): NodeMaterialConnectionPoint;
  22172. /**
  22173. * Gets the source max input component
  22174. */
  22175. get sourceMax(): NodeMaterialConnectionPoint;
  22176. /**
  22177. * Gets the target min input component
  22178. */
  22179. get targetMin(): NodeMaterialConnectionPoint;
  22180. /**
  22181. * Gets the target max input component
  22182. */
  22183. get targetMax(): NodeMaterialConnectionPoint;
  22184. /**
  22185. * Gets the output component
  22186. */
  22187. get output(): NodeMaterialConnectionPoint;
  22188. protected _buildBlock(state: NodeMaterialBuildState): this;
  22189. protected _dumpPropertiesCode(): string;
  22190. serialize(): any;
  22191. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22192. }
  22193. }
  22194. declare module BABYLON {
  22195. /**
  22196. * Block used to multiply 2 values
  22197. */
  22198. export class MultiplyBlock extends NodeMaterialBlock {
  22199. /**
  22200. * Creates a new MultiplyBlock
  22201. * @param name defines the block name
  22202. */
  22203. constructor(name: string);
  22204. /**
  22205. * Gets the current class name
  22206. * @returns the class name
  22207. */
  22208. getClassName(): string;
  22209. /**
  22210. * Gets the left operand input component
  22211. */
  22212. get left(): NodeMaterialConnectionPoint;
  22213. /**
  22214. * Gets the right operand input component
  22215. */
  22216. get right(): NodeMaterialConnectionPoint;
  22217. /**
  22218. * Gets the output component
  22219. */
  22220. get output(): NodeMaterialConnectionPoint;
  22221. protected _buildBlock(state: NodeMaterialBuildState): this;
  22222. }
  22223. }
  22224. declare module BABYLON {
  22225. /**
  22226. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22227. */
  22228. export class ColorSplitterBlock extends NodeMaterialBlock {
  22229. /**
  22230. * Create a new ColorSplitterBlock
  22231. * @param name defines the block name
  22232. */
  22233. constructor(name: string);
  22234. /**
  22235. * Gets the current class name
  22236. * @returns the class name
  22237. */
  22238. getClassName(): string;
  22239. /**
  22240. * Gets the rgba component (input)
  22241. */
  22242. get rgba(): NodeMaterialConnectionPoint;
  22243. /**
  22244. * Gets the rgb component (input)
  22245. */
  22246. get rgbIn(): NodeMaterialConnectionPoint;
  22247. /**
  22248. * Gets the rgb component (output)
  22249. */
  22250. get rgbOut(): NodeMaterialConnectionPoint;
  22251. /**
  22252. * Gets the r component (output)
  22253. */
  22254. get r(): NodeMaterialConnectionPoint;
  22255. /**
  22256. * Gets the g component (output)
  22257. */
  22258. get g(): NodeMaterialConnectionPoint;
  22259. /**
  22260. * Gets the b component (output)
  22261. */
  22262. get b(): NodeMaterialConnectionPoint;
  22263. /**
  22264. * Gets the a component (output)
  22265. */
  22266. get a(): NodeMaterialConnectionPoint;
  22267. protected _inputRename(name: string): string;
  22268. protected _outputRename(name: string): string;
  22269. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22270. }
  22271. }
  22272. declare module BABYLON {
  22273. /**
  22274. * Operations supported by the Trigonometry block
  22275. */
  22276. export enum TrigonometryBlockOperations {
  22277. /** Cos */
  22278. Cos = 0,
  22279. /** Sin */
  22280. Sin = 1,
  22281. /** Abs */
  22282. Abs = 2,
  22283. /** Exp */
  22284. Exp = 3,
  22285. /** Exp2 */
  22286. Exp2 = 4,
  22287. /** Round */
  22288. Round = 5,
  22289. /** Floor */
  22290. Floor = 6,
  22291. /** Ceiling */
  22292. Ceiling = 7,
  22293. /** Square root */
  22294. Sqrt = 8,
  22295. /** Log */
  22296. Log = 9,
  22297. /** Tangent */
  22298. Tan = 10,
  22299. /** Arc tangent */
  22300. ArcTan = 11,
  22301. /** Arc cosinus */
  22302. ArcCos = 12,
  22303. /** Arc sinus */
  22304. ArcSin = 13,
  22305. /** Fraction */
  22306. Fract = 14,
  22307. /** Sign */
  22308. Sign = 15,
  22309. /** To radians (from degrees) */
  22310. Radians = 16,
  22311. /** To degrees (from radians) */
  22312. Degrees = 17
  22313. }
  22314. /**
  22315. * Block used to apply trigonometry operation to floats
  22316. */
  22317. export class TrigonometryBlock extends NodeMaterialBlock {
  22318. /**
  22319. * Gets or sets the operation applied by the block
  22320. */
  22321. operation: TrigonometryBlockOperations;
  22322. /**
  22323. * Creates a new TrigonometryBlock
  22324. * @param name defines the block name
  22325. */
  22326. constructor(name: string);
  22327. /**
  22328. * Gets the current class name
  22329. * @returns the class name
  22330. */
  22331. getClassName(): string;
  22332. /**
  22333. * Gets the input component
  22334. */
  22335. get input(): NodeMaterialConnectionPoint;
  22336. /**
  22337. * Gets the output component
  22338. */
  22339. get output(): NodeMaterialConnectionPoint;
  22340. protected _buildBlock(state: NodeMaterialBuildState): this;
  22341. serialize(): any;
  22342. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22343. protected _dumpPropertiesCode(): string;
  22344. }
  22345. }
  22346. declare module BABYLON {
  22347. /**
  22348. * Interface used to configure the node material editor
  22349. */
  22350. export interface INodeMaterialEditorOptions {
  22351. /** Define the URl to load node editor script */
  22352. editorURL?: string;
  22353. }
  22354. /** @hidden */
  22355. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22356. NORMAL: boolean;
  22357. TANGENT: boolean;
  22358. UV1: boolean;
  22359. /** BONES */
  22360. NUM_BONE_INFLUENCERS: number;
  22361. BonesPerMesh: number;
  22362. BONETEXTURE: boolean;
  22363. /** MORPH TARGETS */
  22364. MORPHTARGETS: boolean;
  22365. MORPHTARGETS_NORMAL: boolean;
  22366. MORPHTARGETS_TANGENT: boolean;
  22367. MORPHTARGETS_UV: boolean;
  22368. NUM_MORPH_INFLUENCERS: number;
  22369. /** IMAGE PROCESSING */
  22370. IMAGEPROCESSING: boolean;
  22371. VIGNETTE: boolean;
  22372. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22373. VIGNETTEBLENDMODEOPAQUE: boolean;
  22374. TONEMAPPING: boolean;
  22375. TONEMAPPING_ACES: boolean;
  22376. CONTRAST: boolean;
  22377. EXPOSURE: boolean;
  22378. COLORCURVES: boolean;
  22379. COLORGRADING: boolean;
  22380. COLORGRADING3D: boolean;
  22381. SAMPLER3DGREENDEPTH: boolean;
  22382. SAMPLER3DBGRMAP: boolean;
  22383. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22384. /** MISC. */
  22385. BUMPDIRECTUV: number;
  22386. constructor();
  22387. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22388. }
  22389. /**
  22390. * Class used to configure NodeMaterial
  22391. */
  22392. export interface INodeMaterialOptions {
  22393. /**
  22394. * Defines if blocks should emit comments
  22395. */
  22396. emitComments: boolean;
  22397. }
  22398. /**
  22399. * Class used to create a node based material built by assembling shader blocks
  22400. */
  22401. export class NodeMaterial extends PushMaterial {
  22402. private static _BuildIdGenerator;
  22403. private _options;
  22404. private _vertexCompilationState;
  22405. private _fragmentCompilationState;
  22406. private _sharedData;
  22407. private _buildId;
  22408. private _buildWasSuccessful;
  22409. private _cachedWorldViewMatrix;
  22410. private _cachedWorldViewProjectionMatrix;
  22411. private _optimizers;
  22412. private _animationFrame;
  22413. /** Define the Url to load node editor script */
  22414. static EditorURL: string;
  22415. /** Define the Url to load snippets */
  22416. static SnippetUrl: string;
  22417. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22418. static IgnoreTexturesAtLoadTime: boolean;
  22419. private BJSNODEMATERIALEDITOR;
  22420. /** Get the inspector from bundle or global */
  22421. private _getGlobalNodeMaterialEditor;
  22422. /**
  22423. * Snippet ID if the material was created from the snippet server
  22424. */
  22425. snippetId: string;
  22426. /**
  22427. * Gets or sets data used by visual editor
  22428. * @see https://nme.babylonjs.com
  22429. */
  22430. editorData: any;
  22431. /**
  22432. * 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)
  22433. */
  22434. ignoreAlpha: boolean;
  22435. /**
  22436. * Defines the maximum number of lights that can be used in the material
  22437. */
  22438. maxSimultaneousLights: number;
  22439. /**
  22440. * Observable raised when the material is built
  22441. */
  22442. onBuildObservable: Observable<NodeMaterial>;
  22443. /**
  22444. * Gets or sets the root nodes of the material vertex shader
  22445. */
  22446. _vertexOutputNodes: NodeMaterialBlock[];
  22447. /**
  22448. * Gets or sets the root nodes of the material fragment (pixel) shader
  22449. */
  22450. _fragmentOutputNodes: NodeMaterialBlock[];
  22451. /** Gets or sets options to control the node material overall behavior */
  22452. get options(): INodeMaterialOptions;
  22453. set options(options: INodeMaterialOptions);
  22454. /**
  22455. * Default configuration related to image processing available in the standard Material.
  22456. */
  22457. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22458. /**
  22459. * Gets the image processing configuration used either in this material.
  22460. */
  22461. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22462. /**
  22463. * Sets the Default image processing configuration used either in the this material.
  22464. *
  22465. * If sets to null, the scene one is in use.
  22466. */
  22467. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22468. /**
  22469. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22470. */
  22471. attachedBlocks: NodeMaterialBlock[];
  22472. /**
  22473. * Specifies the mode of the node material
  22474. * @hidden
  22475. */
  22476. _mode: NodeMaterialModes;
  22477. /**
  22478. * Gets the mode property
  22479. */
  22480. get mode(): NodeMaterialModes;
  22481. /**
  22482. * Create a new node based material
  22483. * @param name defines the material name
  22484. * @param scene defines the hosting scene
  22485. * @param options defines creation option
  22486. */
  22487. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22488. /**
  22489. * Gets the current class name of the material e.g. "NodeMaterial"
  22490. * @returns the class name
  22491. */
  22492. getClassName(): string;
  22493. /**
  22494. * Keep track of the image processing observer to allow dispose and replace.
  22495. */
  22496. private _imageProcessingObserver;
  22497. /**
  22498. * Attaches a new image processing configuration to the Standard Material.
  22499. * @param configuration
  22500. */
  22501. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22502. /**
  22503. * Get a block by its name
  22504. * @param name defines the name of the block to retrieve
  22505. * @returns the required block or null if not found
  22506. */
  22507. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22508. /**
  22509. * Get a block by its name
  22510. * @param predicate defines the predicate used to find the good candidate
  22511. * @returns the required block or null if not found
  22512. */
  22513. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22514. /**
  22515. * Get an input block by its name
  22516. * @param predicate defines the predicate used to find the good candidate
  22517. * @returns the required input block or null if not found
  22518. */
  22519. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22520. /**
  22521. * Gets the list of input blocks attached to this material
  22522. * @returns an array of InputBlocks
  22523. */
  22524. getInputBlocks(): InputBlock[];
  22525. /**
  22526. * Adds a new optimizer to the list of optimizers
  22527. * @param optimizer defines the optimizers to add
  22528. * @returns the current material
  22529. */
  22530. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22531. /**
  22532. * Remove an optimizer from the list of optimizers
  22533. * @param optimizer defines the optimizers to remove
  22534. * @returns the current material
  22535. */
  22536. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22537. /**
  22538. * Add a new block to the list of output nodes
  22539. * @param node defines the node to add
  22540. * @returns the current material
  22541. */
  22542. addOutputNode(node: NodeMaterialBlock): this;
  22543. /**
  22544. * Remove a block from the list of root nodes
  22545. * @param node defines the node to remove
  22546. * @returns the current material
  22547. */
  22548. removeOutputNode(node: NodeMaterialBlock): this;
  22549. private _addVertexOutputNode;
  22550. private _removeVertexOutputNode;
  22551. private _addFragmentOutputNode;
  22552. private _removeFragmentOutputNode;
  22553. /**
  22554. * Specifies if the material will require alpha blending
  22555. * @returns a boolean specifying if alpha blending is needed
  22556. */
  22557. needAlphaBlending(): boolean;
  22558. /**
  22559. * Specifies if this material should be rendered in alpha test mode
  22560. * @returns a boolean specifying if an alpha test is needed.
  22561. */
  22562. needAlphaTesting(): boolean;
  22563. private _initializeBlock;
  22564. private _resetDualBlocks;
  22565. /**
  22566. * Remove a block from the current node material
  22567. * @param block defines the block to remove
  22568. */
  22569. removeBlock(block: NodeMaterialBlock): void;
  22570. /**
  22571. * Build the material and generates the inner effect
  22572. * @param verbose defines if the build should log activity
  22573. */
  22574. build(verbose?: boolean): void;
  22575. /**
  22576. * Runs an otpimization phase to try to improve the shader code
  22577. */
  22578. optimize(): void;
  22579. private _prepareDefinesForAttributes;
  22580. /**
  22581. * Create a post process from the material
  22582. * @param camera The camera to apply the render pass to.
  22583. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22584. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22585. * @param engine The engine which the post process will be applied. (default: current engine)
  22586. * @param reusable If the post process can be reused on the same frame. (default: false)
  22587. * @param textureType Type of textures used when performing the post process. (default: 0)
  22588. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22589. * @returns the post process created
  22590. */
  22591. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  22592. /**
  22593. * Create the post process effect from the material
  22594. * @param postProcess The post process to create the effect for
  22595. */
  22596. createEffectForPostProcess(postProcess: PostProcess): void;
  22597. private _createEffectForPostProcess;
  22598. /**
  22599. * Create a new procedural texture based on this node material
  22600. * @param size defines the size of the texture
  22601. * @param scene defines the hosting scene
  22602. * @returns the new procedural texture attached to this node material
  22603. */
  22604. createProceduralTexture(size: number | {
  22605. width: number;
  22606. height: number;
  22607. layers?: number;
  22608. }, scene: Scene): Nullable<ProceduralTexture>;
  22609. private _createEffectForParticles;
  22610. private _checkInternals;
  22611. /**
  22612. * Create the effect to be used as the custom effect for a particle system
  22613. * @param particleSystem Particle system to create the effect for
  22614. * @param onCompiled defines a function to call when the effect creation is successful
  22615. * @param onError defines a function to call when the effect creation has failed
  22616. */
  22617. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22618. private _processDefines;
  22619. /**
  22620. * Get if the submesh is ready to be used and all its information available.
  22621. * Child classes can use it to update shaders
  22622. * @param mesh defines the mesh to check
  22623. * @param subMesh defines which submesh to check
  22624. * @param useInstances specifies that instances should be used
  22625. * @returns a boolean indicating that the submesh is ready or not
  22626. */
  22627. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22628. /**
  22629. * Get a string representing the shaders built by the current node graph
  22630. */
  22631. get compiledShaders(): string;
  22632. /**
  22633. * Binds the world matrix to the material
  22634. * @param world defines the world transformation matrix
  22635. */
  22636. bindOnlyWorldMatrix(world: Matrix): void;
  22637. /**
  22638. * Binds the submesh to this material by preparing the effect and shader to draw
  22639. * @param world defines the world transformation matrix
  22640. * @param mesh defines the mesh containing the submesh
  22641. * @param subMesh defines the submesh to bind the material to
  22642. */
  22643. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22644. /**
  22645. * Gets the active textures from the material
  22646. * @returns an array of textures
  22647. */
  22648. getActiveTextures(): BaseTexture[];
  22649. /**
  22650. * Gets the list of texture blocks
  22651. * @returns an array of texture blocks
  22652. */
  22653. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22654. /**
  22655. * Specifies if the material uses a texture
  22656. * @param texture defines the texture to check against the material
  22657. * @returns a boolean specifying if the material uses the texture
  22658. */
  22659. hasTexture(texture: BaseTexture): boolean;
  22660. /**
  22661. * Disposes the material
  22662. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22663. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22664. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22665. */
  22666. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22667. /** Creates the node editor window. */
  22668. private _createNodeEditor;
  22669. /**
  22670. * Launch the node material editor
  22671. * @param config Define the configuration of the editor
  22672. * @return a promise fulfilled when the node editor is visible
  22673. */
  22674. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22675. /**
  22676. * Clear the current material
  22677. */
  22678. clear(): void;
  22679. /**
  22680. * Clear the current material and set it to a default state
  22681. */
  22682. setToDefault(): void;
  22683. /**
  22684. * Clear the current material and set it to a default state for post process
  22685. */
  22686. setToDefaultPostProcess(): void;
  22687. /**
  22688. * Clear the current material and set it to a default state for procedural texture
  22689. */
  22690. setToDefaultProceduralTexture(): void;
  22691. /**
  22692. * Clear the current material and set it to a default state for particle
  22693. */
  22694. setToDefaultParticle(): void;
  22695. /**
  22696. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22697. * @param url defines the url to load from
  22698. * @returns a promise that will fullfil when the material is fully loaded
  22699. */
  22700. loadAsync(url: string): Promise<void>;
  22701. private _gatherBlocks;
  22702. /**
  22703. * Generate a string containing the code declaration required to create an equivalent of this material
  22704. * @returns a string
  22705. */
  22706. generateCode(): string;
  22707. /**
  22708. * Serializes this material in a JSON representation
  22709. * @returns the serialized material object
  22710. */
  22711. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22712. private _restoreConnections;
  22713. /**
  22714. * Clear the current graph and load a new one from a serialization object
  22715. * @param source defines the JSON representation of the material
  22716. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22717. * @param merge defines whether or not the source must be merged or replace the current content
  22718. */
  22719. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  22720. /**
  22721. * Makes a duplicate of the current material.
  22722. * @param name - name to use for the new material.
  22723. */
  22724. clone(name: string): NodeMaterial;
  22725. /**
  22726. * Creates a node material from parsed material data
  22727. * @param source defines the JSON representation of the material
  22728. * @param scene defines the hosting scene
  22729. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22730. * @returns a new node material
  22731. */
  22732. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22733. /**
  22734. * Creates a node material from a snippet saved in a remote file
  22735. * @param name defines the name of the material to create
  22736. * @param url defines the url to load from
  22737. * @param scene defines the hosting scene
  22738. * @returns a promise that will resolve to the new node material
  22739. */
  22740. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22741. /**
  22742. * Creates a node material from a snippet saved by the node material editor
  22743. * @param snippetId defines the snippet to load
  22744. * @param scene defines the hosting scene
  22745. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22746. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22747. * @returns a promise that will resolve to the new node material
  22748. */
  22749. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22750. /**
  22751. * Creates a new node material set to default basic configuration
  22752. * @param name defines the name of the material
  22753. * @param scene defines the hosting scene
  22754. * @returns a new NodeMaterial
  22755. */
  22756. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22757. }
  22758. }
  22759. declare module BABYLON {
  22760. /**
  22761. * Size options for a post process
  22762. */
  22763. export type PostProcessOptions = {
  22764. width: number;
  22765. height: number;
  22766. };
  22767. /**
  22768. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22769. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22770. */
  22771. export class PostProcess {
  22772. /**
  22773. * Gets or sets the unique id of the post process
  22774. */
  22775. uniqueId: number;
  22776. /** Name of the PostProcess. */
  22777. name: string;
  22778. /**
  22779. * Width of the texture to apply the post process on
  22780. */
  22781. width: number;
  22782. /**
  22783. * Height of the texture to apply the post process on
  22784. */
  22785. height: number;
  22786. /**
  22787. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22788. */
  22789. nodeMaterialSource: Nullable<NodeMaterial>;
  22790. /**
  22791. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22792. * @hidden
  22793. */
  22794. _outputTexture: Nullable<InternalTexture>;
  22795. /**
  22796. * Sampling mode used by the shader
  22797. * See https://doc.babylonjs.com/classes/3.1/texture
  22798. */
  22799. renderTargetSamplingMode: number;
  22800. /**
  22801. * Clear color to use when screen clearing
  22802. */
  22803. clearColor: Color4;
  22804. /**
  22805. * If the buffer needs to be cleared before applying the post process. (default: true)
  22806. * Should be set to false if shader will overwrite all previous pixels.
  22807. */
  22808. autoClear: boolean;
  22809. /**
  22810. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22811. */
  22812. alphaMode: number;
  22813. /**
  22814. * Sets the setAlphaBlendConstants of the babylon engine
  22815. */
  22816. alphaConstants: Color4;
  22817. /**
  22818. * Animations to be used for the post processing
  22819. */
  22820. animations: Animation[];
  22821. /**
  22822. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22823. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22824. */
  22825. enablePixelPerfectMode: boolean;
  22826. /**
  22827. * Force the postprocess to be applied without taking in account viewport
  22828. */
  22829. forceFullscreenViewport: boolean;
  22830. /**
  22831. * List of inspectable custom properties (used by the Inspector)
  22832. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22833. */
  22834. inspectableCustomProperties: IInspectable[];
  22835. /**
  22836. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22837. *
  22838. * | Value | Type | Description |
  22839. * | ----- | ----------------------------------- | ----------- |
  22840. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22841. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22842. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22843. *
  22844. */
  22845. scaleMode: number;
  22846. /**
  22847. * Force textures to be a power of two (default: false)
  22848. */
  22849. alwaysForcePOT: boolean;
  22850. private _samples;
  22851. /**
  22852. * Number of sample textures (default: 1)
  22853. */
  22854. get samples(): number;
  22855. set samples(n: number);
  22856. /**
  22857. * Modify the scale of the post process to be the same as the viewport (default: false)
  22858. */
  22859. adaptScaleToCurrentViewport: boolean;
  22860. private _camera;
  22861. protected _scene: Scene;
  22862. private _engine;
  22863. private _options;
  22864. private _reusable;
  22865. private _textureType;
  22866. private _textureFormat;
  22867. /**
  22868. * Smart array of input and output textures for the post process.
  22869. * @hidden
  22870. */
  22871. _textures: SmartArray<InternalTexture>;
  22872. /**
  22873. * The index in _textures that corresponds to the output texture.
  22874. * @hidden
  22875. */
  22876. _currentRenderTextureInd: number;
  22877. private _effect;
  22878. private _samplers;
  22879. private _fragmentUrl;
  22880. private _vertexUrl;
  22881. private _parameters;
  22882. private _scaleRatio;
  22883. protected _indexParameters: any;
  22884. private _shareOutputWithPostProcess;
  22885. private _texelSize;
  22886. private _forcedOutputTexture;
  22887. /**
  22888. * Returns the fragment url or shader name used in the post process.
  22889. * @returns the fragment url or name in the shader store.
  22890. */
  22891. getEffectName(): string;
  22892. /**
  22893. * An event triggered when the postprocess is activated.
  22894. */
  22895. onActivateObservable: Observable<Camera>;
  22896. private _onActivateObserver;
  22897. /**
  22898. * A function that is added to the onActivateObservable
  22899. */
  22900. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22901. /**
  22902. * An event triggered when the postprocess changes its size.
  22903. */
  22904. onSizeChangedObservable: Observable<PostProcess>;
  22905. private _onSizeChangedObserver;
  22906. /**
  22907. * A function that is added to the onSizeChangedObservable
  22908. */
  22909. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22910. /**
  22911. * An event triggered when the postprocess applies its effect.
  22912. */
  22913. onApplyObservable: Observable<Effect>;
  22914. private _onApplyObserver;
  22915. /**
  22916. * A function that is added to the onApplyObservable
  22917. */
  22918. set onApply(callback: (effect: Effect) => void);
  22919. /**
  22920. * An event triggered before rendering the postprocess
  22921. */
  22922. onBeforeRenderObservable: Observable<Effect>;
  22923. private _onBeforeRenderObserver;
  22924. /**
  22925. * A function that is added to the onBeforeRenderObservable
  22926. */
  22927. set onBeforeRender(callback: (effect: Effect) => void);
  22928. /**
  22929. * An event triggered after rendering the postprocess
  22930. */
  22931. onAfterRenderObservable: Observable<Effect>;
  22932. private _onAfterRenderObserver;
  22933. /**
  22934. * A function that is added to the onAfterRenderObservable
  22935. */
  22936. set onAfterRender(callback: (efect: Effect) => void);
  22937. /**
  22938. * 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
  22939. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22940. */
  22941. get inputTexture(): InternalTexture;
  22942. set inputTexture(value: InternalTexture);
  22943. /**
  22944. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  22945. * the only way to unset it is to use this function to restore its internal state
  22946. */
  22947. restoreDefaultInputTexture(): void;
  22948. /**
  22949. * Gets the camera which post process is applied to.
  22950. * @returns The camera the post process is applied to.
  22951. */
  22952. getCamera(): Camera;
  22953. /**
  22954. * Gets the texel size of the postprocess.
  22955. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22956. */
  22957. get texelSize(): Vector2;
  22958. /**
  22959. * Creates a new instance PostProcess
  22960. * @param name The name of the PostProcess.
  22961. * @param fragmentUrl The url of the fragment shader to be used.
  22962. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22963. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22964. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22965. * @param camera The camera to apply the render pass to.
  22966. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22967. * @param engine The engine which the post process will be applied. (default: current engine)
  22968. * @param reusable If the post process can be reused on the same frame. (default: false)
  22969. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22970. * @param textureType Type of textures used when performing the post process. (default: 0)
  22971. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22972. * @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
  22973. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  22974. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22975. */
  22976. 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);
  22977. /**
  22978. * Gets a string identifying the name of the class
  22979. * @returns "PostProcess" string
  22980. */
  22981. getClassName(): string;
  22982. /**
  22983. * Gets the engine which this post process belongs to.
  22984. * @returns The engine the post process was enabled with.
  22985. */
  22986. getEngine(): Engine;
  22987. /**
  22988. * The effect that is created when initializing the post process.
  22989. * @returns The created effect corresponding the the postprocess.
  22990. */
  22991. getEffect(): Effect;
  22992. /**
  22993. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22994. * @param postProcess The post process to share the output with.
  22995. * @returns This post process.
  22996. */
  22997. shareOutputWith(postProcess: PostProcess): PostProcess;
  22998. /**
  22999. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23000. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23001. */
  23002. useOwnOutput(): void;
  23003. /**
  23004. * Updates the effect with the current post process compile time values and recompiles the shader.
  23005. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23006. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23007. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23008. * @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
  23009. * @param onCompiled Called when the shader has been compiled.
  23010. * @param onError Called if there is an error when compiling a shader.
  23011. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23012. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23013. */
  23014. 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;
  23015. /**
  23016. * The post process is reusable if it can be used multiple times within one frame.
  23017. * @returns If the post process is reusable
  23018. */
  23019. isReusable(): boolean;
  23020. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23021. markTextureDirty(): void;
  23022. /**
  23023. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23024. * 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.
  23025. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23026. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23027. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23028. * @returns The target texture that was bound to be written to.
  23029. */
  23030. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23031. /**
  23032. * If the post process is supported.
  23033. */
  23034. get isSupported(): boolean;
  23035. /**
  23036. * The aspect ratio of the output texture.
  23037. */
  23038. get aspectRatio(): number;
  23039. /**
  23040. * Get a value indicating if the post-process is ready to be used
  23041. * @returns true if the post-process is ready (shader is compiled)
  23042. */
  23043. isReady(): boolean;
  23044. /**
  23045. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23046. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23047. */
  23048. apply(): Nullable<Effect>;
  23049. private _disposeTextures;
  23050. /**
  23051. * Disposes the post process.
  23052. * @param camera The camera to dispose the post process on.
  23053. */
  23054. dispose(camera?: Camera): void;
  23055. /**
  23056. * Serializes the particle system to a JSON object
  23057. * @returns the JSON object
  23058. */
  23059. serialize(): any;
  23060. /**
  23061. * Creates a material from parsed material data
  23062. * @param parsedPostProcess defines parsed post process data
  23063. * @param scene defines the hosting scene
  23064. * @param rootUrl defines the root URL to use to load textures
  23065. * @returns a new post process
  23066. */
  23067. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23068. }
  23069. }
  23070. declare module BABYLON {
  23071. /** @hidden */
  23072. export var kernelBlurVaryingDeclaration: {
  23073. name: string;
  23074. shader: string;
  23075. };
  23076. }
  23077. declare module BABYLON {
  23078. /** @hidden */
  23079. export var kernelBlurFragment: {
  23080. name: string;
  23081. shader: string;
  23082. };
  23083. }
  23084. declare module BABYLON {
  23085. /** @hidden */
  23086. export var kernelBlurFragment2: {
  23087. name: string;
  23088. shader: string;
  23089. };
  23090. }
  23091. declare module BABYLON {
  23092. /** @hidden */
  23093. export var kernelBlurPixelShader: {
  23094. name: string;
  23095. shader: string;
  23096. };
  23097. }
  23098. declare module BABYLON {
  23099. /** @hidden */
  23100. export var kernelBlurVertex: {
  23101. name: string;
  23102. shader: string;
  23103. };
  23104. }
  23105. declare module BABYLON {
  23106. /** @hidden */
  23107. export var kernelBlurVertexShader: {
  23108. name: string;
  23109. shader: string;
  23110. };
  23111. }
  23112. declare module BABYLON {
  23113. /**
  23114. * The Blur Post Process which blurs an image based on a kernel and direction.
  23115. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23116. */
  23117. export class BlurPostProcess extends PostProcess {
  23118. private blockCompilation;
  23119. protected _kernel: number;
  23120. protected _idealKernel: number;
  23121. protected _packedFloat: boolean;
  23122. private _staticDefines;
  23123. /** The direction in which to blur the image. */
  23124. direction: Vector2;
  23125. /**
  23126. * Sets the length in pixels of the blur sample region
  23127. */
  23128. set kernel(v: number);
  23129. /**
  23130. * Gets the length in pixels of the blur sample region
  23131. */
  23132. get kernel(): number;
  23133. /**
  23134. * Sets wether or not the blur needs to unpack/repack floats
  23135. */
  23136. set packedFloat(v: boolean);
  23137. /**
  23138. * Gets wether or not the blur is unpacking/repacking floats
  23139. */
  23140. get packedFloat(): boolean;
  23141. /**
  23142. * Gets a string identifying the name of the class
  23143. * @returns "BlurPostProcess" string
  23144. */
  23145. getClassName(): string;
  23146. /**
  23147. * Creates a new instance BlurPostProcess
  23148. * @param name The name of the effect.
  23149. * @param direction The direction in which to blur the image.
  23150. * @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.
  23151. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23152. * @param camera The camera to apply the render pass to.
  23153. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23154. * @param engine The engine which the post process will be applied. (default: current engine)
  23155. * @param reusable If the post process can be reused on the same frame. (default: false)
  23156. * @param textureType Type of textures used when performing the post process. (default: 0)
  23157. * @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)
  23158. */
  23159. 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);
  23160. /**
  23161. * Updates the effect with the current post process compile time values and recompiles the shader.
  23162. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23163. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23164. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23165. * @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
  23166. * @param onCompiled Called when the shader has been compiled.
  23167. * @param onError Called if there is an error when compiling a shader.
  23168. */
  23169. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23170. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23171. /**
  23172. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23173. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23174. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23175. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23176. * The gaps between physical kernels are compensated for in the weighting of the samples
  23177. * @param idealKernel Ideal blur kernel.
  23178. * @return Nearest best kernel.
  23179. */
  23180. protected _nearestBestKernel(idealKernel: number): number;
  23181. /**
  23182. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23183. * @param x The point on the Gaussian distribution to sample.
  23184. * @return the value of the Gaussian function at x.
  23185. */
  23186. protected _gaussianWeight(x: number): number;
  23187. /**
  23188. * Generates a string that can be used as a floating point number in GLSL.
  23189. * @param x Value to print.
  23190. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23191. * @return GLSL float string.
  23192. */
  23193. protected _glslFloat(x: number, decimalFigures?: number): string;
  23194. /** @hidden */
  23195. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  23196. }
  23197. }
  23198. declare module BABYLON {
  23199. /**
  23200. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23201. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23202. * You can then easily use it as a reflectionTexture on a flat surface.
  23203. * In case the surface is not a plane, please consider relying on reflection probes.
  23204. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23205. */
  23206. export class MirrorTexture extends RenderTargetTexture {
  23207. private scene;
  23208. /**
  23209. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23210. * 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.
  23211. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23212. */
  23213. mirrorPlane: Plane;
  23214. /**
  23215. * Define the blur ratio used to blur the reflection if needed.
  23216. */
  23217. set blurRatio(value: number);
  23218. get blurRatio(): number;
  23219. /**
  23220. * Define the adaptive blur kernel used to blur the reflection if needed.
  23221. * This will autocompute the closest best match for the `blurKernel`
  23222. */
  23223. set adaptiveBlurKernel(value: number);
  23224. /**
  23225. * Define the blur kernel used to blur the reflection if needed.
  23226. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23227. */
  23228. set blurKernel(value: number);
  23229. /**
  23230. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23231. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23232. */
  23233. set blurKernelX(value: number);
  23234. get blurKernelX(): number;
  23235. /**
  23236. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23237. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23238. */
  23239. set blurKernelY(value: number);
  23240. get blurKernelY(): number;
  23241. private _autoComputeBlurKernel;
  23242. protected _onRatioRescale(): void;
  23243. private _updateGammaSpace;
  23244. private _imageProcessingConfigChangeObserver;
  23245. private _transformMatrix;
  23246. private _mirrorMatrix;
  23247. private _savedViewMatrix;
  23248. private _blurX;
  23249. private _blurY;
  23250. private _adaptiveBlurKernel;
  23251. private _blurKernelX;
  23252. private _blurKernelY;
  23253. private _blurRatio;
  23254. /**
  23255. * Instantiates a Mirror Texture.
  23256. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23257. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23258. * You can then easily use it as a reflectionTexture on a flat surface.
  23259. * In case the surface is not a plane, please consider relying on reflection probes.
  23260. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23261. * @param name
  23262. * @param size
  23263. * @param scene
  23264. * @param generateMipMaps
  23265. * @param type
  23266. * @param samplingMode
  23267. * @param generateDepthBuffer
  23268. */
  23269. constructor(name: string, size: number | {
  23270. width: number;
  23271. height: number;
  23272. } | {
  23273. ratio: number;
  23274. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23275. private _preparePostProcesses;
  23276. /**
  23277. * Clone the mirror texture.
  23278. * @returns the cloned texture
  23279. */
  23280. clone(): MirrorTexture;
  23281. /**
  23282. * Serialize the texture to a JSON representation you could use in Parse later on
  23283. * @returns the serialized JSON representation
  23284. */
  23285. serialize(): any;
  23286. /**
  23287. * Dispose the texture and release its associated resources.
  23288. */
  23289. dispose(): void;
  23290. }
  23291. }
  23292. declare module BABYLON {
  23293. /**
  23294. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23295. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23296. */
  23297. export class Texture extends BaseTexture {
  23298. /**
  23299. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23300. */
  23301. static SerializeBuffers: boolean;
  23302. /** @hidden */
  23303. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23304. /** @hidden */
  23305. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23306. /** @hidden */
  23307. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23308. /** nearest is mag = nearest and min = nearest and mip = linear */
  23309. static readonly NEAREST_SAMPLINGMODE: number;
  23310. /** nearest is mag = nearest and min = nearest and mip = linear */
  23311. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23312. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23313. static readonly BILINEAR_SAMPLINGMODE: number;
  23314. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23315. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23316. /** Trilinear is mag = linear and min = linear and mip = linear */
  23317. static readonly TRILINEAR_SAMPLINGMODE: number;
  23318. /** Trilinear is mag = linear and min = linear and mip = linear */
  23319. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23320. /** mag = nearest and min = nearest and mip = nearest */
  23321. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23322. /** mag = nearest and min = linear and mip = nearest */
  23323. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23324. /** mag = nearest and min = linear and mip = linear */
  23325. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23326. /** mag = nearest and min = linear and mip = none */
  23327. static readonly NEAREST_LINEAR: number;
  23328. /** mag = nearest and min = nearest and mip = none */
  23329. static readonly NEAREST_NEAREST: number;
  23330. /** mag = linear and min = nearest and mip = nearest */
  23331. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23332. /** mag = linear and min = nearest and mip = linear */
  23333. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23334. /** mag = linear and min = linear and mip = none */
  23335. static readonly LINEAR_LINEAR: number;
  23336. /** mag = linear and min = nearest and mip = none */
  23337. static readonly LINEAR_NEAREST: number;
  23338. /** Explicit coordinates mode */
  23339. static readonly EXPLICIT_MODE: number;
  23340. /** Spherical coordinates mode */
  23341. static readonly SPHERICAL_MODE: number;
  23342. /** Planar coordinates mode */
  23343. static readonly PLANAR_MODE: number;
  23344. /** Cubic coordinates mode */
  23345. static readonly CUBIC_MODE: number;
  23346. /** Projection coordinates mode */
  23347. static readonly PROJECTION_MODE: number;
  23348. /** Inverse Cubic coordinates mode */
  23349. static readonly SKYBOX_MODE: number;
  23350. /** Inverse Cubic coordinates mode */
  23351. static readonly INVCUBIC_MODE: number;
  23352. /** Equirectangular coordinates mode */
  23353. static readonly EQUIRECTANGULAR_MODE: number;
  23354. /** Equirectangular Fixed coordinates mode */
  23355. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23356. /** Equirectangular Fixed Mirrored coordinates mode */
  23357. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23358. /** Texture is not repeating outside of 0..1 UVs */
  23359. static readonly CLAMP_ADDRESSMODE: number;
  23360. /** Texture is repeating outside of 0..1 UVs */
  23361. static readonly WRAP_ADDRESSMODE: number;
  23362. /** Texture is repeating and mirrored */
  23363. static readonly MIRROR_ADDRESSMODE: number;
  23364. /**
  23365. * 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
  23366. */
  23367. static UseSerializedUrlIfAny: boolean;
  23368. /**
  23369. * Define the url of the texture.
  23370. */
  23371. url: Nullable<string>;
  23372. /**
  23373. * Define an offset on the texture to offset the u coordinates of the UVs
  23374. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23375. */
  23376. uOffset: number;
  23377. /**
  23378. * Define an offset on the texture to offset the v coordinates of the UVs
  23379. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23380. */
  23381. vOffset: number;
  23382. /**
  23383. * Define an offset on the texture to scale the u coordinates of the UVs
  23384. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23385. */
  23386. uScale: number;
  23387. /**
  23388. * Define an offset on the texture to scale the v coordinates of the UVs
  23389. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23390. */
  23391. vScale: number;
  23392. /**
  23393. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23394. * @see https://doc.babylonjs.com/how_to/more_materials
  23395. */
  23396. uAng: number;
  23397. /**
  23398. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23399. * @see https://doc.babylonjs.com/how_to/more_materials
  23400. */
  23401. vAng: number;
  23402. /**
  23403. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23404. * @see https://doc.babylonjs.com/how_to/more_materials
  23405. */
  23406. wAng: number;
  23407. /**
  23408. * Defines the center of rotation (U)
  23409. */
  23410. uRotationCenter: number;
  23411. /**
  23412. * Defines the center of rotation (V)
  23413. */
  23414. vRotationCenter: number;
  23415. /**
  23416. * Defines the center of rotation (W)
  23417. */
  23418. wRotationCenter: number;
  23419. /**
  23420. * Are mip maps generated for this texture or not.
  23421. */
  23422. get noMipmap(): boolean;
  23423. /**
  23424. * List of inspectable custom properties (used by the Inspector)
  23425. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23426. */
  23427. inspectableCustomProperties: Nullable<IInspectable[]>;
  23428. private _noMipmap;
  23429. /** @hidden */
  23430. _invertY: boolean;
  23431. private _rowGenerationMatrix;
  23432. private _cachedTextureMatrix;
  23433. private _projectionModeMatrix;
  23434. private _t0;
  23435. private _t1;
  23436. private _t2;
  23437. private _cachedUOffset;
  23438. private _cachedVOffset;
  23439. private _cachedUScale;
  23440. private _cachedVScale;
  23441. private _cachedUAng;
  23442. private _cachedVAng;
  23443. private _cachedWAng;
  23444. private _cachedProjectionMatrixId;
  23445. private _cachedCoordinatesMode;
  23446. /** @hidden */
  23447. protected _initialSamplingMode: number;
  23448. /** @hidden */
  23449. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23450. private _deleteBuffer;
  23451. protected _format: Nullable<number>;
  23452. private _delayedOnLoad;
  23453. private _delayedOnError;
  23454. private _mimeType?;
  23455. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  23456. get mimeType(): string | undefined;
  23457. /**
  23458. * Observable triggered once the texture has been loaded.
  23459. */
  23460. onLoadObservable: Observable<Texture>;
  23461. protected _isBlocking: boolean;
  23462. /**
  23463. * Is the texture preventing material to render while loading.
  23464. * If false, a default texture will be used instead of the loading one during the preparation step.
  23465. */
  23466. set isBlocking(value: boolean);
  23467. get isBlocking(): boolean;
  23468. /**
  23469. * Get the current sampling mode associated with the texture.
  23470. */
  23471. get samplingMode(): number;
  23472. /**
  23473. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23474. */
  23475. get invertY(): boolean;
  23476. /**
  23477. * Instantiates a new texture.
  23478. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23479. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23480. * @param url defines the url of the picture to load as a texture
  23481. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23482. * @param noMipmap defines if the texture will require mip maps or not
  23483. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23484. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23485. * @param onLoad defines a callback triggered when the texture has been loaded
  23486. * @param onError defines a callback triggered when an error occurred during the loading session
  23487. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23488. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23489. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23490. * @param mimeType defines an optional mime type information
  23491. */
  23492. 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);
  23493. /**
  23494. * Update the url (and optional buffer) of this texture if url was null during construction.
  23495. * @param url the url of the texture
  23496. * @param buffer the buffer of the texture (defaults to null)
  23497. * @param onLoad callback called when the texture is loaded (defaults to null)
  23498. */
  23499. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23500. /**
  23501. * Finish the loading sequence of a texture flagged as delayed load.
  23502. * @hidden
  23503. */
  23504. delayLoad(): void;
  23505. private _prepareRowForTextureGeneration;
  23506. /**
  23507. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23508. * @returns the transform matrix of the texture.
  23509. */
  23510. getTextureMatrix(uBase?: number): Matrix;
  23511. /**
  23512. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23513. * @returns The reflection texture transform
  23514. */
  23515. getReflectionTextureMatrix(): Matrix;
  23516. /**
  23517. * Clones the texture.
  23518. * @returns the cloned texture
  23519. */
  23520. clone(): Texture;
  23521. /**
  23522. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23523. * @returns The JSON representation of the texture
  23524. */
  23525. serialize(): any;
  23526. /**
  23527. * Get the current class name of the texture useful for serialization or dynamic coding.
  23528. * @returns "Texture"
  23529. */
  23530. getClassName(): string;
  23531. /**
  23532. * Dispose the texture and release its associated resources.
  23533. */
  23534. dispose(): void;
  23535. /**
  23536. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23537. * @param parsedTexture Define the JSON representation of the texture
  23538. * @param scene Define the scene the parsed texture should be instantiated in
  23539. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23540. * @returns The parsed texture if successful
  23541. */
  23542. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23543. /**
  23544. * Creates a texture from its base 64 representation.
  23545. * @param data Define the base64 payload without the data: prefix
  23546. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23547. * @param scene Define the scene the texture should belong to
  23548. * @param noMipmap Forces the texture to not create mip map information if true
  23549. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23550. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23551. * @param onLoad define a callback triggered when the texture has been loaded
  23552. * @param onError define a callback triggered when an error occurred during the loading session
  23553. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23554. * @returns the created texture
  23555. */
  23556. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23557. /**
  23558. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23559. * @param data Define the base64 payload without the data: prefix
  23560. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23561. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23562. * @param scene Define the scene the texture should belong to
  23563. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23564. * @param noMipmap Forces the texture to not create mip map information if true
  23565. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23566. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23567. * @param onLoad define a callback triggered when the texture has been loaded
  23568. * @param onError define a callback triggered when an error occurred during the loading session
  23569. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23570. * @returns the created texture
  23571. */
  23572. 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;
  23573. }
  23574. }
  23575. declare module BABYLON {
  23576. /**
  23577. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23578. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23579. */
  23580. export class PostProcessManager {
  23581. private _scene;
  23582. private _indexBuffer;
  23583. private _vertexBuffers;
  23584. /**
  23585. * Creates a new instance PostProcess
  23586. * @param scene The scene that the post process is associated with.
  23587. */
  23588. constructor(scene: Scene);
  23589. private _prepareBuffers;
  23590. private _buildIndexBuffer;
  23591. /**
  23592. * Rebuilds the vertex buffers of the manager.
  23593. * @hidden
  23594. */
  23595. _rebuild(): void;
  23596. /**
  23597. * Prepares a frame to be run through a post process.
  23598. * @param sourceTexture The input texture to the post procesess. (default: null)
  23599. * @param postProcesses An array of post processes to be run. (default: null)
  23600. * @returns True if the post processes were able to be run.
  23601. * @hidden
  23602. */
  23603. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23604. /**
  23605. * Manually render a set of post processes to a texture.
  23606. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23607. * @param postProcesses An array of post processes to be run.
  23608. * @param targetTexture The target texture to render to.
  23609. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23610. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23611. * @param lodLevel defines which lod of the texture to render to
  23612. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  23613. */
  23614. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  23615. /**
  23616. * Finalize the result of the output of the postprocesses.
  23617. * @param doNotPresent If true the result will not be displayed to the screen.
  23618. * @param targetTexture The target texture to render to.
  23619. * @param faceIndex The index of the face to bind the target texture to.
  23620. * @param postProcesses The array of post processes to render.
  23621. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23622. * @hidden
  23623. */
  23624. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23625. /**
  23626. * Disposes of the post process manager.
  23627. */
  23628. dispose(): void;
  23629. }
  23630. }
  23631. declare module BABYLON {
  23632. /**
  23633. * This Helps creating a texture that will be created from a camera in your scene.
  23634. * It is basically a dynamic texture that could be used to create special effects for instance.
  23635. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  23636. */
  23637. export class RenderTargetTexture extends Texture {
  23638. /**
  23639. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  23640. */
  23641. static readonly REFRESHRATE_RENDER_ONCE: number;
  23642. /**
  23643. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  23644. */
  23645. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  23646. /**
  23647. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  23648. * the central point of your effect and can save a lot of performances.
  23649. */
  23650. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  23651. /**
  23652. * Use this predicate to dynamically define the list of mesh you want to render.
  23653. * If set, the renderList property will be overwritten.
  23654. */
  23655. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  23656. private _renderList;
  23657. /**
  23658. * Use this list to define the list of mesh you want to render.
  23659. */
  23660. get renderList(): Nullable<Array<AbstractMesh>>;
  23661. set renderList(value: Nullable<Array<AbstractMesh>>);
  23662. /**
  23663. * Use this function to overload the renderList array at rendering time.
  23664. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  23665. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  23666. * the cube (if the RTT is a cube, else layerOrFace=0).
  23667. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  23668. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  23669. * hold dummy elements!
  23670. */
  23671. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  23672. private _hookArray;
  23673. /**
  23674. * Define if particles should be rendered in your texture.
  23675. */
  23676. renderParticles: boolean;
  23677. /**
  23678. * Define if sprites should be rendered in your texture.
  23679. */
  23680. renderSprites: boolean;
  23681. /**
  23682. * Define the camera used to render the texture.
  23683. */
  23684. activeCamera: Nullable<Camera>;
  23685. /**
  23686. * Override the mesh isReady function with your own one.
  23687. */
  23688. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  23689. /**
  23690. * Override the render function of the texture with your own one.
  23691. */
  23692. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  23693. /**
  23694. * Define if camera post processes should be use while rendering the texture.
  23695. */
  23696. useCameraPostProcesses: boolean;
  23697. /**
  23698. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  23699. */
  23700. ignoreCameraViewport: boolean;
  23701. private _postProcessManager;
  23702. private _postProcesses;
  23703. private _resizeObserver;
  23704. /**
  23705. * An event triggered when the texture is unbind.
  23706. */
  23707. onBeforeBindObservable: Observable<RenderTargetTexture>;
  23708. /**
  23709. * An event triggered when the texture is unbind.
  23710. */
  23711. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  23712. private _onAfterUnbindObserver;
  23713. /**
  23714. * Set a after unbind callback in the texture.
  23715. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  23716. */
  23717. set onAfterUnbind(callback: () => void);
  23718. /**
  23719. * An event triggered before rendering the texture
  23720. */
  23721. onBeforeRenderObservable: Observable<number>;
  23722. private _onBeforeRenderObserver;
  23723. /**
  23724. * Set a before render callback in the texture.
  23725. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  23726. */
  23727. set onBeforeRender(callback: (faceIndex: number) => void);
  23728. /**
  23729. * An event triggered after rendering the texture
  23730. */
  23731. onAfterRenderObservable: Observable<number>;
  23732. private _onAfterRenderObserver;
  23733. /**
  23734. * Set a after render callback in the texture.
  23735. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  23736. */
  23737. set onAfterRender(callback: (faceIndex: number) => void);
  23738. /**
  23739. * An event triggered after the texture clear
  23740. */
  23741. onClearObservable: Observable<Engine>;
  23742. private _onClearObserver;
  23743. /**
  23744. * Set a clear callback in the texture.
  23745. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  23746. */
  23747. set onClear(callback: (Engine: Engine) => void);
  23748. /**
  23749. * An event triggered when the texture is resized.
  23750. */
  23751. onResizeObservable: Observable<RenderTargetTexture>;
  23752. /**
  23753. * Define the clear color of the Render Target if it should be different from the scene.
  23754. */
  23755. clearColor: Color4;
  23756. protected _size: number | {
  23757. width: number;
  23758. height: number;
  23759. layers?: number;
  23760. };
  23761. protected _initialSizeParameter: number | {
  23762. width: number;
  23763. height: number;
  23764. } | {
  23765. ratio: number;
  23766. };
  23767. protected _sizeRatio: Nullable<number>;
  23768. /** @hidden */
  23769. _generateMipMaps: boolean;
  23770. protected _renderingManager: RenderingManager;
  23771. /** @hidden */
  23772. _waitingRenderList?: string[];
  23773. protected _doNotChangeAspectRatio: boolean;
  23774. protected _currentRefreshId: number;
  23775. protected _refreshRate: number;
  23776. protected _textureMatrix: Matrix;
  23777. protected _samples: number;
  23778. protected _renderTargetOptions: RenderTargetCreationOptions;
  23779. /**
  23780. * Gets render target creation options that were used.
  23781. */
  23782. get renderTargetOptions(): RenderTargetCreationOptions;
  23783. protected _onRatioRescale(): void;
  23784. /**
  23785. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  23786. * It must define where the camera used to render the texture is set
  23787. */
  23788. boundingBoxPosition: Vector3;
  23789. private _boundingBoxSize;
  23790. /**
  23791. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  23792. * When defined, the cubemap will switch to local mode
  23793. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  23794. * @example https://www.babylonjs-playground.com/#RNASML
  23795. */
  23796. set boundingBoxSize(value: Vector3);
  23797. get boundingBoxSize(): Vector3;
  23798. /**
  23799. * In case the RTT has been created with a depth texture, get the associated
  23800. * depth texture.
  23801. * Otherwise, return null.
  23802. */
  23803. get depthStencilTexture(): Nullable<InternalTexture>;
  23804. /**
  23805. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  23806. * or used a shadow, depth texture...
  23807. * @param name The friendly name of the texture
  23808. * @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)
  23809. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  23810. * @param generateMipMaps True if mip maps need to be generated after render.
  23811. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  23812. * @param type The type of the buffer in the RTT (int, half float, float...)
  23813. * @param isCube True if a cube texture needs to be created
  23814. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  23815. * @param generateDepthBuffer True to generate a depth buffer
  23816. * @param generateStencilBuffer True to generate a stencil buffer
  23817. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  23818. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  23819. * @param delayAllocation if the texture allocation should be delayed (default: false)
  23820. */
  23821. constructor(name: string, size: number | {
  23822. width: number;
  23823. height: number;
  23824. layers?: number;
  23825. } | {
  23826. ratio: number;
  23827. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  23828. /**
  23829. * Creates a depth stencil texture.
  23830. * This is only available in WebGL 2 or with the depth texture extension available.
  23831. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  23832. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  23833. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  23834. */
  23835. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  23836. private _processSizeParameter;
  23837. /**
  23838. * Define the number of samples to use in case of MSAA.
  23839. * It defaults to one meaning no MSAA has been enabled.
  23840. */
  23841. get samples(): number;
  23842. set samples(value: number);
  23843. /**
  23844. * Resets the refresh counter of the texture and start bak from scratch.
  23845. * Could be useful to regenerate the texture if it is setup to render only once.
  23846. */
  23847. resetRefreshCounter(): void;
  23848. /**
  23849. * Define the refresh rate of the texture or the rendering frequency.
  23850. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  23851. */
  23852. get refreshRate(): number;
  23853. set refreshRate(value: number);
  23854. /**
  23855. * Adds a post process to the render target rendering passes.
  23856. * @param postProcess define the post process to add
  23857. */
  23858. addPostProcess(postProcess: PostProcess): void;
  23859. /**
  23860. * Clear all the post processes attached to the render target
  23861. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  23862. */
  23863. clearPostProcesses(dispose?: boolean): void;
  23864. /**
  23865. * Remove one of the post process from the list of attached post processes to the texture
  23866. * @param postProcess define the post process to remove from the list
  23867. */
  23868. removePostProcess(postProcess: PostProcess): void;
  23869. /** @hidden */
  23870. _shouldRender(): boolean;
  23871. /**
  23872. * Gets the actual render size of the texture.
  23873. * @returns the width of the render size
  23874. */
  23875. getRenderSize(): number;
  23876. /**
  23877. * Gets the actual render width of the texture.
  23878. * @returns the width of the render size
  23879. */
  23880. getRenderWidth(): number;
  23881. /**
  23882. * Gets the actual render height of the texture.
  23883. * @returns the height of the render size
  23884. */
  23885. getRenderHeight(): number;
  23886. /**
  23887. * Gets the actual number of layers of the texture.
  23888. * @returns the number of layers
  23889. */
  23890. getRenderLayers(): number;
  23891. /**
  23892. * Get if the texture can be rescaled or not.
  23893. */
  23894. get canRescale(): boolean;
  23895. /**
  23896. * Resize the texture using a ratio.
  23897. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  23898. */
  23899. scale(ratio: number): void;
  23900. /**
  23901. * Get the texture reflection matrix used to rotate/transform the reflection.
  23902. * @returns the reflection matrix
  23903. */
  23904. getReflectionTextureMatrix(): Matrix;
  23905. /**
  23906. * Resize the texture to a new desired size.
  23907. * Be carrefull as it will recreate all the data in the new texture.
  23908. * @param size Define the new size. It can be:
  23909. * - a number for squared texture,
  23910. * - an object containing { width: number, height: number }
  23911. * - or an object containing a ratio { ratio: number }
  23912. */
  23913. resize(size: number | {
  23914. width: number;
  23915. height: number;
  23916. } | {
  23917. ratio: number;
  23918. }): void;
  23919. private _defaultRenderListPrepared;
  23920. /**
  23921. * Renders all the objects from the render list into the texture.
  23922. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  23923. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  23924. */
  23925. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  23926. private _bestReflectionRenderTargetDimension;
  23927. private _prepareRenderingManager;
  23928. /**
  23929. * @hidden
  23930. * @param faceIndex face index to bind to if this is a cubetexture
  23931. * @param layer defines the index of the texture to bind in the array
  23932. */
  23933. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  23934. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23935. private renderToTarget;
  23936. /**
  23937. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  23938. * This allowed control for front to back rendering or reversly depending of the special needs.
  23939. *
  23940. * @param renderingGroupId The rendering group id corresponding to its index
  23941. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  23942. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  23943. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  23944. */
  23945. 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;
  23946. /**
  23947. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  23948. *
  23949. * @param renderingGroupId The rendering group id corresponding to its index
  23950. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  23951. */
  23952. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  23953. /**
  23954. * Clones the texture.
  23955. * @returns the cloned texture
  23956. */
  23957. clone(): RenderTargetTexture;
  23958. /**
  23959. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23960. * @returns The JSON representation of the texture
  23961. */
  23962. serialize(): any;
  23963. /**
  23964. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  23965. */
  23966. disposeFramebufferObjects(): void;
  23967. /**
  23968. * Dispose the texture and release its associated resources.
  23969. */
  23970. dispose(): void;
  23971. /** @hidden */
  23972. _rebuild(): void;
  23973. /**
  23974. * Clear the info related to rendering groups preventing retention point in material dispose.
  23975. */
  23976. freeRenderingGroups(): void;
  23977. /**
  23978. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  23979. * @returns the view count
  23980. */
  23981. getViewCount(): number;
  23982. }
  23983. }
  23984. declare module BABYLON {
  23985. /**
  23986. * Class used to manipulate GUIDs
  23987. */
  23988. export class GUID {
  23989. /**
  23990. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23991. * Be aware Math.random() could cause collisions, but:
  23992. * "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"
  23993. * @returns a pseudo random id
  23994. */
  23995. static RandomId(): string;
  23996. }
  23997. }
  23998. declare module BABYLON {
  23999. /**
  24000. * Options to be used when creating a shadow depth material
  24001. */
  24002. export interface IIOptionShadowDepthMaterial {
  24003. /** Variables in the vertex shader code that need to have their names remapped.
  24004. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  24005. * "var_name" should be either: worldPos or vNormalW
  24006. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  24007. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  24008. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  24009. */
  24010. remappedVariables?: string[];
  24011. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  24012. standalone?: boolean;
  24013. }
  24014. /**
  24015. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  24016. */
  24017. export class ShadowDepthWrapper {
  24018. private _scene;
  24019. private _options?;
  24020. private _baseMaterial;
  24021. private _onEffectCreatedObserver;
  24022. private _subMeshToEffect;
  24023. private _subMeshToDepthEffect;
  24024. private _meshes;
  24025. /** @hidden */
  24026. _matriceNames: any;
  24027. /** Gets the standalone status of the wrapper */
  24028. get standalone(): boolean;
  24029. /** Gets the base material the wrapper is built upon */
  24030. get baseMaterial(): Material;
  24031. /**
  24032. * Instantiate a new shadow depth wrapper.
  24033. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  24034. * generate the shadow depth map. For more information, please refer to the documentation:
  24035. * https://doc.babylonjs.com/babylon101/shadows
  24036. * @param baseMaterial Material to wrap
  24037. * @param scene Define the scene the material belongs to
  24038. * @param options Options used to create the wrapper
  24039. */
  24040. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  24041. /**
  24042. * Gets the effect to use to generate the depth map
  24043. * @param subMesh subMesh to get the effect for
  24044. * @param shadowGenerator shadow generator to get the effect for
  24045. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  24046. */
  24047. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  24048. /**
  24049. * Specifies that the submesh is ready to be used for depth rendering
  24050. * @param subMesh submesh to check
  24051. * @param defines the list of defines to take into account when checking the effect
  24052. * @param shadowGenerator combined with subMesh, it defines the effect to check
  24053. * @param useInstances specifies that instances should be used
  24054. * @returns a boolean indicating that the submesh is ready or not
  24055. */
  24056. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  24057. /**
  24058. * Disposes the resources
  24059. */
  24060. dispose(): void;
  24061. private _makeEffect;
  24062. }
  24063. }
  24064. declare module BABYLON {
  24065. interface ThinEngine {
  24066. /**
  24067. * Unbind a list of render target textures from the webGL context
  24068. * This is used only when drawBuffer extension or webGL2 are active
  24069. * @param textures defines the render target textures to unbind
  24070. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  24071. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  24072. */
  24073. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  24074. /**
  24075. * Create a multi render target texture
  24076. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  24077. * @param size defines the size of the texture
  24078. * @param options defines the creation options
  24079. * @returns the cube texture as an InternalTexture
  24080. */
  24081. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  24082. /**
  24083. * Update the sample count for a given multiple render target texture
  24084. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  24085. * @param textures defines the textures to update
  24086. * @param samples defines the sample count to set
  24087. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  24088. */
  24089. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  24090. /**
  24091. * Select a subsets of attachments to draw to.
  24092. * @param attachments gl attachments
  24093. */
  24094. bindAttachments(attachments: number[]): void;
  24095. }
  24096. }
  24097. declare module BABYLON {
  24098. /**
  24099. * Creation options of the multi render target texture.
  24100. */
  24101. export interface IMultiRenderTargetOptions {
  24102. /**
  24103. * Define if the texture needs to create mip maps after render.
  24104. */
  24105. generateMipMaps?: boolean;
  24106. /**
  24107. * Define the types of all the draw buffers we want to create
  24108. */
  24109. types?: number[];
  24110. /**
  24111. * Define the sampling modes of all the draw buffers we want to create
  24112. */
  24113. samplingModes?: number[];
  24114. /**
  24115. * Define if a depth buffer is required
  24116. */
  24117. generateDepthBuffer?: boolean;
  24118. /**
  24119. * Define if a stencil buffer is required
  24120. */
  24121. generateStencilBuffer?: boolean;
  24122. /**
  24123. * Define if a depth texture is required instead of a depth buffer
  24124. */
  24125. generateDepthTexture?: boolean;
  24126. /**
  24127. * Define the number of desired draw buffers
  24128. */
  24129. textureCount?: number;
  24130. /**
  24131. * Define if aspect ratio should be adapted to the texture or stay the scene one
  24132. */
  24133. doNotChangeAspectRatio?: boolean;
  24134. /**
  24135. * Define the default type of the buffers we are creating
  24136. */
  24137. defaultType?: number;
  24138. }
  24139. /**
  24140. * A multi render target, like a render target provides the ability to render to a texture.
  24141. * Unlike the render target, it can render to several draw buffers in one draw.
  24142. * This is specially interesting in deferred rendering or for any effects requiring more than
  24143. * just one color from a single pass.
  24144. */
  24145. export class MultiRenderTarget extends RenderTargetTexture {
  24146. private _internalTextures;
  24147. private _textures;
  24148. private _multiRenderTargetOptions;
  24149. private _count;
  24150. /**
  24151. * Get if draw buffers are currently supported by the used hardware and browser.
  24152. */
  24153. get isSupported(): boolean;
  24154. /**
  24155. * Get the list of textures generated by the multi render target.
  24156. */
  24157. get textures(): Texture[];
  24158. /**
  24159. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  24160. */
  24161. get count(): number;
  24162. /**
  24163. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  24164. */
  24165. get depthTexture(): Texture;
  24166. /**
  24167. * Set the wrapping mode on U of all the textures we are rendering to.
  24168. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24169. */
  24170. set wrapU(wrap: number);
  24171. /**
  24172. * Set the wrapping mode on V of all the textures we are rendering to.
  24173. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24174. */
  24175. set wrapV(wrap: number);
  24176. /**
  24177. * Instantiate a new multi render target texture.
  24178. * A multi render target, like a render target provides the ability to render to a texture.
  24179. * Unlike the render target, it can render to several draw buffers in one draw.
  24180. * This is specially interesting in deferred rendering or for any effects requiring more than
  24181. * just one color from a single pass.
  24182. * @param name Define the name of the texture
  24183. * @param size Define the size of the buffers to render to
  24184. * @param count Define the number of target we are rendering into
  24185. * @param scene Define the scene the texture belongs to
  24186. * @param options Define the options used to create the multi render target
  24187. */
  24188. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  24189. private _initTypes;
  24190. /** @hidden */
  24191. _rebuild(forceFullRebuild?: boolean): void;
  24192. private _createInternalTextures;
  24193. private _createTextures;
  24194. /**
  24195. * Define the number of samples used if MSAA is enabled.
  24196. */
  24197. get samples(): number;
  24198. set samples(value: number);
  24199. /**
  24200. * Resize all the textures in the multi render target.
  24201. * Be careful as it will recreate all the data in the new texture.
  24202. * @param size Define the new size
  24203. */
  24204. resize(size: any): void;
  24205. /**
  24206. * Changes the number of render targets in this MRT
  24207. * Be careful as it will recreate all the data in the new texture.
  24208. * @param count new texture count
  24209. * @param options Specifies texture types and sampling modes for new textures
  24210. */
  24211. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  24212. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24213. /**
  24214. * Dispose the render targets and their associated resources
  24215. */
  24216. dispose(): void;
  24217. /**
  24218. * Release all the underlying texture used as draw buffers.
  24219. */
  24220. releaseInternalTextures(): void;
  24221. }
  24222. }
  24223. declare module BABYLON {
  24224. /** @hidden */
  24225. export var imageProcessingPixelShader: {
  24226. name: string;
  24227. shader: string;
  24228. };
  24229. }
  24230. declare module BABYLON {
  24231. /**
  24232. * ImageProcessingPostProcess
  24233. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  24234. */
  24235. export class ImageProcessingPostProcess extends PostProcess {
  24236. /**
  24237. * Default configuration related to image processing available in the PBR Material.
  24238. */
  24239. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24240. /**
  24241. * Gets the image processing configuration used either in this material.
  24242. */
  24243. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  24244. /**
  24245. * Sets the Default image processing configuration used either in the this material.
  24246. *
  24247. * If sets to null, the scene one is in use.
  24248. */
  24249. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  24250. /**
  24251. * Keep track of the image processing observer to allow dispose and replace.
  24252. */
  24253. private _imageProcessingObserver;
  24254. /**
  24255. * Attaches a new image processing configuration to the PBR Material.
  24256. * @param configuration
  24257. */
  24258. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  24259. /**
  24260. * If the post process is supported.
  24261. */
  24262. get isSupported(): boolean;
  24263. /**
  24264. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24265. */
  24266. get colorCurves(): Nullable<ColorCurves>;
  24267. /**
  24268. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24269. */
  24270. set colorCurves(value: Nullable<ColorCurves>);
  24271. /**
  24272. * Gets wether the color curves effect is enabled.
  24273. */
  24274. get colorCurvesEnabled(): boolean;
  24275. /**
  24276. * Sets wether the color curves effect is enabled.
  24277. */
  24278. set colorCurvesEnabled(value: boolean);
  24279. /**
  24280. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24281. */
  24282. get colorGradingTexture(): Nullable<BaseTexture>;
  24283. /**
  24284. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24285. */
  24286. set colorGradingTexture(value: Nullable<BaseTexture>);
  24287. /**
  24288. * Gets wether the color grading effect is enabled.
  24289. */
  24290. get colorGradingEnabled(): boolean;
  24291. /**
  24292. * Gets wether the color grading effect is enabled.
  24293. */
  24294. set colorGradingEnabled(value: boolean);
  24295. /**
  24296. * Gets exposure used in the effect.
  24297. */
  24298. get exposure(): number;
  24299. /**
  24300. * Sets exposure used in the effect.
  24301. */
  24302. set exposure(value: number);
  24303. /**
  24304. * Gets wether tonemapping is enabled or not.
  24305. */
  24306. get toneMappingEnabled(): boolean;
  24307. /**
  24308. * Sets wether tonemapping is enabled or not
  24309. */
  24310. set toneMappingEnabled(value: boolean);
  24311. /**
  24312. * Gets the type of tone mapping effect.
  24313. */
  24314. get toneMappingType(): number;
  24315. /**
  24316. * Sets the type of tone mapping effect.
  24317. */
  24318. set toneMappingType(value: number);
  24319. /**
  24320. * Gets contrast used in the effect.
  24321. */
  24322. get contrast(): number;
  24323. /**
  24324. * Sets contrast used in the effect.
  24325. */
  24326. set contrast(value: number);
  24327. /**
  24328. * Gets Vignette stretch size.
  24329. */
  24330. get vignetteStretch(): number;
  24331. /**
  24332. * Sets Vignette stretch size.
  24333. */
  24334. set vignetteStretch(value: number);
  24335. /**
  24336. * Gets Vignette centre X Offset.
  24337. */
  24338. get vignetteCentreX(): number;
  24339. /**
  24340. * Sets Vignette centre X Offset.
  24341. */
  24342. set vignetteCentreX(value: number);
  24343. /**
  24344. * Gets Vignette centre Y Offset.
  24345. */
  24346. get vignetteCentreY(): number;
  24347. /**
  24348. * Sets Vignette centre Y Offset.
  24349. */
  24350. set vignetteCentreY(value: number);
  24351. /**
  24352. * Gets Vignette weight or intensity of the vignette effect.
  24353. */
  24354. get vignetteWeight(): number;
  24355. /**
  24356. * Sets Vignette weight or intensity of the vignette effect.
  24357. */
  24358. set vignetteWeight(value: number);
  24359. /**
  24360. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24361. * if vignetteEnabled is set to true.
  24362. */
  24363. get vignetteColor(): Color4;
  24364. /**
  24365. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24366. * if vignetteEnabled is set to true.
  24367. */
  24368. set vignetteColor(value: Color4);
  24369. /**
  24370. * Gets Camera field of view used by the Vignette effect.
  24371. */
  24372. get vignetteCameraFov(): number;
  24373. /**
  24374. * Sets Camera field of view used by the Vignette effect.
  24375. */
  24376. set vignetteCameraFov(value: number);
  24377. /**
  24378. * Gets the vignette blend mode allowing different kind of effect.
  24379. */
  24380. get vignetteBlendMode(): number;
  24381. /**
  24382. * Sets the vignette blend mode allowing different kind of effect.
  24383. */
  24384. set vignetteBlendMode(value: number);
  24385. /**
  24386. * Gets wether the vignette effect is enabled.
  24387. */
  24388. get vignetteEnabled(): boolean;
  24389. /**
  24390. * Sets wether the vignette effect is enabled.
  24391. */
  24392. set vignetteEnabled(value: boolean);
  24393. private _fromLinearSpace;
  24394. /**
  24395. * Gets wether the input of the processing is in Gamma or Linear Space.
  24396. */
  24397. get fromLinearSpace(): boolean;
  24398. /**
  24399. * Sets wether the input of the processing is in Gamma or Linear Space.
  24400. */
  24401. set fromLinearSpace(value: boolean);
  24402. /**
  24403. * Defines cache preventing GC.
  24404. */
  24405. private _defines;
  24406. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  24407. /**
  24408. * "ImageProcessingPostProcess"
  24409. * @returns "ImageProcessingPostProcess"
  24410. */
  24411. getClassName(): string;
  24412. /**
  24413. * @hidden
  24414. */
  24415. _updateParameters(): void;
  24416. dispose(camera?: Camera): void;
  24417. }
  24418. }
  24419. declare module BABYLON {
  24420. /**
  24421. * Interface for defining prepass effects in the prepass post-process pipeline
  24422. */
  24423. export interface PrePassEffectConfiguration {
  24424. /**
  24425. * Name of the effect
  24426. */
  24427. name: string;
  24428. /**
  24429. * Post process to attach for this effect
  24430. */
  24431. postProcess?: PostProcess;
  24432. /**
  24433. * Textures required in the MRT
  24434. */
  24435. texturesRequired: number[];
  24436. /**
  24437. * Is the effect enabled
  24438. */
  24439. enabled: boolean;
  24440. /**
  24441. * Disposes the effect configuration
  24442. */
  24443. dispose(): void;
  24444. /**
  24445. * Creates the associated post process
  24446. */
  24447. createPostProcess?: () => PostProcess;
  24448. }
  24449. }
  24450. declare module BABYLON {
  24451. /**
  24452. * Renders a pre pass of the scene
  24453. * This means every mesh in the scene will be rendered to a render target texture
  24454. * And then this texture will be composited to the rendering canvas with post processes
  24455. * It is necessary for effects like subsurface scattering or deferred shading
  24456. */
  24457. export class PrePassRenderer {
  24458. /** @hidden */
  24459. static _SceneComponentInitialization: (scene: Scene) => void;
  24460. private _textureFormats;
  24461. private _textureIndices;
  24462. private _scene;
  24463. private _engine;
  24464. private _isDirty;
  24465. /**
  24466. * Number of textures in the multi render target texture where the scene is directly rendered
  24467. */
  24468. mrtCount: number;
  24469. /**
  24470. * The render target where the scene is directly rendered
  24471. */
  24472. prePassRT: MultiRenderTarget;
  24473. private _multiRenderAttachments;
  24474. private _defaultAttachments;
  24475. private _clearAttachments;
  24476. private _postProcesses;
  24477. private readonly _clearColor;
  24478. /**
  24479. * Image processing post process for composition
  24480. */
  24481. imageProcessingPostProcess: ImageProcessingPostProcess;
  24482. /**
  24483. * Configuration for prepass effects
  24484. */
  24485. private _effectConfigurations;
  24486. /**
  24487. * Should materials render their geometry on the MRT
  24488. */
  24489. materialsShouldRenderGeometry: boolean;
  24490. /**
  24491. * Should materials render the irradiance information on the MRT
  24492. */
  24493. materialsShouldRenderIrradiance: boolean;
  24494. private _mrtFormats;
  24495. private _mrtLayout;
  24496. private _enabled;
  24497. /**
  24498. * Indicates if the prepass is enabled
  24499. */
  24500. get enabled(): boolean;
  24501. /**
  24502. * How many samples are used for MSAA of the scene render target
  24503. */
  24504. get samples(): number;
  24505. set samples(n: number);
  24506. /**
  24507. * Instanciates a prepass renderer
  24508. * @param scene The scene
  24509. */
  24510. constructor(scene: Scene);
  24511. private _initializeAttachments;
  24512. private _createCompositionEffect;
  24513. /**
  24514. * Indicates if rendering a prepass is supported
  24515. */
  24516. get isSupported(): boolean;
  24517. /**
  24518. * Sets the proper output textures to draw in the engine.
  24519. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  24520. */
  24521. bindAttachmentsForEffect(effect: Effect): void;
  24522. /**
  24523. * @hidden
  24524. */
  24525. _beforeCameraDraw(): void;
  24526. /**
  24527. * @hidden
  24528. */
  24529. _afterCameraDraw(): void;
  24530. private _checkRTSize;
  24531. private _bindFrameBuffer;
  24532. /**
  24533. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  24534. */
  24535. clear(): void;
  24536. private _setState;
  24537. private _checkTextureType;
  24538. /**
  24539. * Adds an effect configuration to the prepass.
  24540. * If an effect has already been added, it won't add it twice and will return the configuration
  24541. * already present.
  24542. * @param cfg the effect configuration
  24543. * @return the effect configuration now used by the prepass
  24544. */
  24545. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  24546. /**
  24547. * Returns the index of a texture in the multi render target texture array.
  24548. * @param type Texture type
  24549. * @return The index
  24550. */
  24551. getIndex(type: number): number;
  24552. private _enable;
  24553. private _disable;
  24554. private _resetLayout;
  24555. private _resetPostProcessChain;
  24556. private _bindPostProcessChain;
  24557. /**
  24558. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  24559. */
  24560. markAsDirty(): void;
  24561. /**
  24562. * Enables a texture on the MultiRenderTarget for prepass
  24563. */
  24564. private _enableTextures;
  24565. private _update;
  24566. /**
  24567. * Disposes the prepass renderer.
  24568. */
  24569. dispose(): void;
  24570. }
  24571. }
  24572. declare module BABYLON {
  24573. /**
  24574. * Options for compiling materials.
  24575. */
  24576. export interface IMaterialCompilationOptions {
  24577. /**
  24578. * Defines whether clip planes are enabled.
  24579. */
  24580. clipPlane: boolean;
  24581. /**
  24582. * Defines whether instances are enabled.
  24583. */
  24584. useInstances: boolean;
  24585. }
  24586. /**
  24587. * Options passed when calling customShaderNameResolve
  24588. */
  24589. export interface ICustomShaderNameResolveOptions {
  24590. /**
  24591. * 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
  24592. */
  24593. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  24594. }
  24595. /**
  24596. * Base class for the main features of a material in Babylon.js
  24597. */
  24598. export class Material implements IAnimatable {
  24599. /**
  24600. * Returns the triangle fill mode
  24601. */
  24602. static readonly TriangleFillMode: number;
  24603. /**
  24604. * Returns the wireframe mode
  24605. */
  24606. static readonly WireFrameFillMode: number;
  24607. /**
  24608. * Returns the point fill mode
  24609. */
  24610. static readonly PointFillMode: number;
  24611. /**
  24612. * Returns the point list draw mode
  24613. */
  24614. static readonly PointListDrawMode: number;
  24615. /**
  24616. * Returns the line list draw mode
  24617. */
  24618. static readonly LineListDrawMode: number;
  24619. /**
  24620. * Returns the line loop draw mode
  24621. */
  24622. static readonly LineLoopDrawMode: number;
  24623. /**
  24624. * Returns the line strip draw mode
  24625. */
  24626. static readonly LineStripDrawMode: number;
  24627. /**
  24628. * Returns the triangle strip draw mode
  24629. */
  24630. static readonly TriangleStripDrawMode: number;
  24631. /**
  24632. * Returns the triangle fan draw mode
  24633. */
  24634. static readonly TriangleFanDrawMode: number;
  24635. /**
  24636. * Stores the clock-wise side orientation
  24637. */
  24638. static readonly ClockWiseSideOrientation: number;
  24639. /**
  24640. * Stores the counter clock-wise side orientation
  24641. */
  24642. static readonly CounterClockWiseSideOrientation: number;
  24643. /**
  24644. * The dirty texture flag value
  24645. */
  24646. static readonly TextureDirtyFlag: number;
  24647. /**
  24648. * The dirty light flag value
  24649. */
  24650. static readonly LightDirtyFlag: number;
  24651. /**
  24652. * The dirty fresnel flag value
  24653. */
  24654. static readonly FresnelDirtyFlag: number;
  24655. /**
  24656. * The dirty attribute flag value
  24657. */
  24658. static readonly AttributesDirtyFlag: number;
  24659. /**
  24660. * The dirty misc flag value
  24661. */
  24662. static readonly MiscDirtyFlag: number;
  24663. /**
  24664. * The all dirty flag value
  24665. */
  24666. static readonly AllDirtyFlag: number;
  24667. /**
  24668. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  24669. */
  24670. static readonly MATERIAL_OPAQUE: number;
  24671. /**
  24672. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  24673. */
  24674. static readonly MATERIAL_ALPHATEST: number;
  24675. /**
  24676. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24677. */
  24678. static readonly MATERIAL_ALPHABLEND: number;
  24679. /**
  24680. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24681. * They are also discarded below the alpha cutoff threshold to improve performances.
  24682. */
  24683. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  24684. /**
  24685. * The Whiteout method is used to blend normals.
  24686. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24687. */
  24688. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  24689. /**
  24690. * The Reoriented Normal Mapping method is used to blend normals.
  24691. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24692. */
  24693. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  24694. /**
  24695. * Custom callback helping to override the default shader used in the material.
  24696. */
  24697. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  24698. /**
  24699. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  24700. */
  24701. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  24702. /**
  24703. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  24704. * This means that the material can keep using a previous shader while a new one is being compiled.
  24705. * This is mostly used when shader parallel compilation is supported (true by default)
  24706. */
  24707. allowShaderHotSwapping: boolean;
  24708. /**
  24709. * The ID of the material
  24710. */
  24711. id: string;
  24712. /**
  24713. * Gets or sets the unique id of the material
  24714. */
  24715. uniqueId: number;
  24716. /**
  24717. * The name of the material
  24718. */
  24719. name: string;
  24720. /**
  24721. * Gets or sets user defined metadata
  24722. */
  24723. metadata: any;
  24724. /**
  24725. * For internal use only. Please do not use.
  24726. */
  24727. reservedDataStore: any;
  24728. /**
  24729. * Specifies if the ready state should be checked on each call
  24730. */
  24731. checkReadyOnEveryCall: boolean;
  24732. /**
  24733. * Specifies if the ready state should be checked once
  24734. */
  24735. checkReadyOnlyOnce: boolean;
  24736. /**
  24737. * The state of the material
  24738. */
  24739. state: string;
  24740. /**
  24741. * If the material can be rendered to several textures with MRT extension
  24742. */
  24743. get canRenderToMRT(): boolean;
  24744. /**
  24745. * The alpha value of the material
  24746. */
  24747. protected _alpha: number;
  24748. /**
  24749. * List of inspectable custom properties (used by the Inspector)
  24750. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24751. */
  24752. inspectableCustomProperties: IInspectable[];
  24753. /**
  24754. * Sets the alpha value of the material
  24755. */
  24756. set alpha(value: number);
  24757. /**
  24758. * Gets the alpha value of the material
  24759. */
  24760. get alpha(): number;
  24761. /**
  24762. * Specifies if back face culling is enabled
  24763. */
  24764. protected _backFaceCulling: boolean;
  24765. /**
  24766. * Sets the back-face culling state
  24767. */
  24768. set backFaceCulling(value: boolean);
  24769. /**
  24770. * Gets the back-face culling state
  24771. */
  24772. get backFaceCulling(): boolean;
  24773. /**
  24774. * Stores the value for side orientation
  24775. */
  24776. sideOrientation: number;
  24777. /**
  24778. * Callback triggered when the material is compiled
  24779. */
  24780. onCompiled: Nullable<(effect: Effect) => void>;
  24781. /**
  24782. * Callback triggered when an error occurs
  24783. */
  24784. onError: Nullable<(effect: Effect, errors: string) => void>;
  24785. /**
  24786. * Callback triggered to get the render target textures
  24787. */
  24788. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  24789. /**
  24790. * Gets a boolean indicating that current material needs to register RTT
  24791. */
  24792. get hasRenderTargetTextures(): boolean;
  24793. /**
  24794. * Specifies if the material should be serialized
  24795. */
  24796. doNotSerialize: boolean;
  24797. /**
  24798. * @hidden
  24799. */
  24800. _storeEffectOnSubMeshes: boolean;
  24801. /**
  24802. * Stores the animations for the material
  24803. */
  24804. animations: Nullable<Array<Animation>>;
  24805. /**
  24806. * An event triggered when the material is disposed
  24807. */
  24808. onDisposeObservable: Observable<Material>;
  24809. /**
  24810. * An observer which watches for dispose events
  24811. */
  24812. private _onDisposeObserver;
  24813. private _onUnBindObservable;
  24814. /**
  24815. * Called during a dispose event
  24816. */
  24817. set onDispose(callback: () => void);
  24818. private _onBindObservable;
  24819. /**
  24820. * An event triggered when the material is bound
  24821. */
  24822. get onBindObservable(): Observable<AbstractMesh>;
  24823. /**
  24824. * An observer which watches for bind events
  24825. */
  24826. private _onBindObserver;
  24827. /**
  24828. * Called during a bind event
  24829. */
  24830. set onBind(callback: (Mesh: AbstractMesh) => void);
  24831. /**
  24832. * An event triggered when the material is unbound
  24833. */
  24834. get onUnBindObservable(): Observable<Material>;
  24835. protected _onEffectCreatedObservable: Nullable<Observable<{
  24836. effect: Effect;
  24837. subMesh: Nullable<SubMesh>;
  24838. }>>;
  24839. /**
  24840. * An event triggered when the effect is (re)created
  24841. */
  24842. get onEffectCreatedObservable(): Observable<{
  24843. effect: Effect;
  24844. subMesh: Nullable<SubMesh>;
  24845. }>;
  24846. /**
  24847. * Stores the value of the alpha mode
  24848. */
  24849. private _alphaMode;
  24850. /**
  24851. * Sets the value of the alpha mode.
  24852. *
  24853. * | Value | Type | Description |
  24854. * | --- | --- | --- |
  24855. * | 0 | ALPHA_DISABLE | |
  24856. * | 1 | ALPHA_ADD | |
  24857. * | 2 | ALPHA_COMBINE | |
  24858. * | 3 | ALPHA_SUBTRACT | |
  24859. * | 4 | ALPHA_MULTIPLY | |
  24860. * | 5 | ALPHA_MAXIMIZED | |
  24861. * | 6 | ALPHA_ONEONE | |
  24862. * | 7 | ALPHA_PREMULTIPLIED | |
  24863. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  24864. * | 9 | ALPHA_INTERPOLATE | |
  24865. * | 10 | ALPHA_SCREENMODE | |
  24866. *
  24867. */
  24868. set alphaMode(value: number);
  24869. /**
  24870. * Gets the value of the alpha mode
  24871. */
  24872. get alphaMode(): number;
  24873. /**
  24874. * Stores the state of the need depth pre-pass value
  24875. */
  24876. private _needDepthPrePass;
  24877. /**
  24878. * Sets the need depth pre-pass value
  24879. */
  24880. set needDepthPrePass(value: boolean);
  24881. /**
  24882. * Gets the depth pre-pass value
  24883. */
  24884. get needDepthPrePass(): boolean;
  24885. /**
  24886. * Specifies if depth writing should be disabled
  24887. */
  24888. disableDepthWrite: boolean;
  24889. /**
  24890. * Specifies if color writing should be disabled
  24891. */
  24892. disableColorWrite: boolean;
  24893. /**
  24894. * Specifies if depth writing should be forced
  24895. */
  24896. forceDepthWrite: boolean;
  24897. /**
  24898. * Specifies the depth function that should be used. 0 means the default engine function
  24899. */
  24900. depthFunction: number;
  24901. /**
  24902. * Specifies if there should be a separate pass for culling
  24903. */
  24904. separateCullingPass: boolean;
  24905. /**
  24906. * Stores the state specifing if fog should be enabled
  24907. */
  24908. private _fogEnabled;
  24909. /**
  24910. * Sets the state for enabling fog
  24911. */
  24912. set fogEnabled(value: boolean);
  24913. /**
  24914. * Gets the value of the fog enabled state
  24915. */
  24916. get fogEnabled(): boolean;
  24917. /**
  24918. * Stores the size of points
  24919. */
  24920. pointSize: number;
  24921. /**
  24922. * Stores the z offset value
  24923. */
  24924. zOffset: number;
  24925. get wireframe(): boolean;
  24926. /**
  24927. * Sets the state of wireframe mode
  24928. */
  24929. set wireframe(value: boolean);
  24930. /**
  24931. * Gets the value specifying if point clouds are enabled
  24932. */
  24933. get pointsCloud(): boolean;
  24934. /**
  24935. * Sets the state of point cloud mode
  24936. */
  24937. set pointsCloud(value: boolean);
  24938. /**
  24939. * Gets the material fill mode
  24940. */
  24941. get fillMode(): number;
  24942. /**
  24943. * Sets the material fill mode
  24944. */
  24945. set fillMode(value: number);
  24946. /**
  24947. * @hidden
  24948. * Stores the effects for the material
  24949. */
  24950. _effect: Nullable<Effect>;
  24951. /**
  24952. * Specifies if uniform buffers should be used
  24953. */
  24954. private _useUBO;
  24955. /**
  24956. * Stores a reference to the scene
  24957. */
  24958. private _scene;
  24959. /**
  24960. * Stores the fill mode state
  24961. */
  24962. private _fillMode;
  24963. /**
  24964. * Specifies if the depth write state should be cached
  24965. */
  24966. private _cachedDepthWriteState;
  24967. /**
  24968. * Specifies if the color write state should be cached
  24969. */
  24970. private _cachedColorWriteState;
  24971. /**
  24972. * Specifies if the depth function state should be cached
  24973. */
  24974. private _cachedDepthFunctionState;
  24975. /**
  24976. * Stores the uniform buffer
  24977. */
  24978. protected _uniformBuffer: UniformBuffer;
  24979. /** @hidden */
  24980. _indexInSceneMaterialArray: number;
  24981. /** @hidden */
  24982. meshMap: Nullable<{
  24983. [id: string]: AbstractMesh | undefined;
  24984. }>;
  24985. /**
  24986. * Creates a material instance
  24987. * @param name defines the name of the material
  24988. * @param scene defines the scene to reference
  24989. * @param doNotAdd specifies if the material should be added to the scene
  24990. */
  24991. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24992. /**
  24993. * Returns a string representation of the current material
  24994. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24995. * @returns a string with material information
  24996. */
  24997. toString(fullDetails?: boolean): string;
  24998. /**
  24999. * Gets the class name of the material
  25000. * @returns a string with the class name of the material
  25001. */
  25002. getClassName(): string;
  25003. /**
  25004. * Specifies if updates for the material been locked
  25005. */
  25006. get isFrozen(): boolean;
  25007. /**
  25008. * Locks updates for the material
  25009. */
  25010. freeze(): void;
  25011. /**
  25012. * Unlocks updates for the material
  25013. */
  25014. unfreeze(): void;
  25015. /**
  25016. * Specifies if the material is ready to be used
  25017. * @param mesh defines the mesh to check
  25018. * @param useInstances specifies if instances should be used
  25019. * @returns a boolean indicating if the material is ready to be used
  25020. */
  25021. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  25022. /**
  25023. * Specifies that the submesh is ready to be used
  25024. * @param mesh defines the mesh to check
  25025. * @param subMesh defines which submesh to check
  25026. * @param useInstances specifies that instances should be used
  25027. * @returns a boolean indicating that the submesh is ready or not
  25028. */
  25029. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25030. /**
  25031. * Returns the material effect
  25032. * @returns the effect associated with the material
  25033. */
  25034. getEffect(): Nullable<Effect>;
  25035. /**
  25036. * Returns the current scene
  25037. * @returns a Scene
  25038. */
  25039. getScene(): Scene;
  25040. /**
  25041. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  25042. */
  25043. protected _forceAlphaTest: boolean;
  25044. /**
  25045. * The transparency mode of the material.
  25046. */
  25047. protected _transparencyMode: Nullable<number>;
  25048. /**
  25049. * Gets the current transparency mode.
  25050. */
  25051. get transparencyMode(): Nullable<number>;
  25052. /**
  25053. * Sets the transparency mode of the material.
  25054. *
  25055. * | Value | Type | Description |
  25056. * | ----- | ----------------------------------- | ----------- |
  25057. * | 0 | OPAQUE | |
  25058. * | 1 | ALPHATEST | |
  25059. * | 2 | ALPHABLEND | |
  25060. * | 3 | ALPHATESTANDBLEND | |
  25061. *
  25062. */
  25063. set transparencyMode(value: Nullable<number>);
  25064. /**
  25065. * Returns true if alpha blending should be disabled.
  25066. */
  25067. protected get _disableAlphaBlending(): boolean;
  25068. /**
  25069. * Specifies whether or not this material should be rendered in alpha blend mode.
  25070. * @returns a boolean specifying if alpha blending is needed
  25071. */
  25072. needAlphaBlending(): boolean;
  25073. /**
  25074. * Specifies if the mesh will require alpha blending
  25075. * @param mesh defines the mesh to check
  25076. * @returns a boolean specifying if alpha blending is needed for the mesh
  25077. */
  25078. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  25079. /**
  25080. * Specifies whether or not this material should be rendered in alpha test mode.
  25081. * @returns a boolean specifying if an alpha test is needed.
  25082. */
  25083. needAlphaTesting(): boolean;
  25084. /**
  25085. * Specifies if material alpha testing should be turned on for the mesh
  25086. * @param mesh defines the mesh to check
  25087. */
  25088. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  25089. /**
  25090. * Gets the texture used for the alpha test
  25091. * @returns the texture to use for alpha testing
  25092. */
  25093. getAlphaTestTexture(): Nullable<BaseTexture>;
  25094. /**
  25095. * Marks the material to indicate that it needs to be re-calculated
  25096. */
  25097. markDirty(): void;
  25098. /** @hidden */
  25099. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  25100. /**
  25101. * Binds the material to the mesh
  25102. * @param world defines the world transformation matrix
  25103. * @param mesh defines the mesh to bind the material to
  25104. */
  25105. bind(world: Matrix, mesh?: Mesh): void;
  25106. /**
  25107. * Binds the submesh to the material
  25108. * @param world defines the world transformation matrix
  25109. * @param mesh defines the mesh containing the submesh
  25110. * @param subMesh defines the submesh to bind the material to
  25111. */
  25112. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25113. /**
  25114. * Binds the world matrix to the material
  25115. * @param world defines the world transformation matrix
  25116. */
  25117. bindOnlyWorldMatrix(world: Matrix): void;
  25118. /**
  25119. * Binds the scene's uniform buffer to the effect.
  25120. * @param effect defines the effect to bind to the scene uniform buffer
  25121. * @param sceneUbo defines the uniform buffer storing scene data
  25122. */
  25123. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  25124. /**
  25125. * Binds the view matrix to the effect
  25126. * @param effect defines the effect to bind the view matrix to
  25127. */
  25128. bindView(effect: Effect): void;
  25129. /**
  25130. * Binds the view projection matrix to the effect
  25131. * @param effect defines the effect to bind the view projection matrix to
  25132. */
  25133. bindViewProjection(effect: Effect): void;
  25134. /**
  25135. * Processes to execute after binding the material to a mesh
  25136. * @param mesh defines the rendered mesh
  25137. */
  25138. protected _afterBind(mesh?: Mesh): void;
  25139. /**
  25140. * Unbinds the material from the mesh
  25141. */
  25142. unbind(): void;
  25143. /**
  25144. * Gets the active textures from the material
  25145. * @returns an array of textures
  25146. */
  25147. getActiveTextures(): BaseTexture[];
  25148. /**
  25149. * Specifies if the material uses a texture
  25150. * @param texture defines the texture to check against the material
  25151. * @returns a boolean specifying if the material uses the texture
  25152. */
  25153. hasTexture(texture: BaseTexture): boolean;
  25154. /**
  25155. * Makes a duplicate of the material, and gives it a new name
  25156. * @param name defines the new name for the duplicated material
  25157. * @returns the cloned material
  25158. */
  25159. clone(name: string): Nullable<Material>;
  25160. /**
  25161. * Gets the meshes bound to the material
  25162. * @returns an array of meshes bound to the material
  25163. */
  25164. getBindedMeshes(): AbstractMesh[];
  25165. /**
  25166. * Force shader compilation
  25167. * @param mesh defines the mesh associated with this material
  25168. * @param onCompiled defines a function to execute once the material is compiled
  25169. * @param options defines the options to configure the compilation
  25170. * @param onError defines a function to execute if the material fails compiling
  25171. */
  25172. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  25173. /**
  25174. * Force shader compilation
  25175. * @param mesh defines the mesh that will use this material
  25176. * @param options defines additional options for compiling the shaders
  25177. * @returns a promise that resolves when the compilation completes
  25178. */
  25179. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  25180. private static readonly _AllDirtyCallBack;
  25181. private static readonly _ImageProcessingDirtyCallBack;
  25182. private static readonly _TextureDirtyCallBack;
  25183. private static readonly _FresnelDirtyCallBack;
  25184. private static readonly _MiscDirtyCallBack;
  25185. private static readonly _LightsDirtyCallBack;
  25186. private static readonly _AttributeDirtyCallBack;
  25187. private static _FresnelAndMiscDirtyCallBack;
  25188. private static _TextureAndMiscDirtyCallBack;
  25189. private static readonly _DirtyCallbackArray;
  25190. private static readonly _RunDirtyCallBacks;
  25191. /**
  25192. * Marks a define in the material to indicate that it needs to be re-computed
  25193. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  25194. */
  25195. markAsDirty(flag: number): void;
  25196. /**
  25197. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  25198. * @param func defines a function which checks material defines against the submeshes
  25199. */
  25200. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  25201. /**
  25202. * Indicates that the scene should check if the rendering now needs a prepass
  25203. */
  25204. protected _markScenePrePassDirty(): void;
  25205. /**
  25206. * Indicates that we need to re-calculated for all submeshes
  25207. */
  25208. protected _markAllSubMeshesAsAllDirty(): void;
  25209. /**
  25210. * Indicates that image processing needs to be re-calculated for all submeshes
  25211. */
  25212. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  25213. /**
  25214. * Indicates that textures need to be re-calculated for all submeshes
  25215. */
  25216. protected _markAllSubMeshesAsTexturesDirty(): void;
  25217. /**
  25218. * Indicates that fresnel needs to be re-calculated for all submeshes
  25219. */
  25220. protected _markAllSubMeshesAsFresnelDirty(): void;
  25221. /**
  25222. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  25223. */
  25224. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  25225. /**
  25226. * Indicates that lights need to be re-calculated for all submeshes
  25227. */
  25228. protected _markAllSubMeshesAsLightsDirty(): void;
  25229. /**
  25230. * Indicates that attributes need to be re-calculated for all submeshes
  25231. */
  25232. protected _markAllSubMeshesAsAttributesDirty(): void;
  25233. /**
  25234. * Indicates that misc needs to be re-calculated for all submeshes
  25235. */
  25236. protected _markAllSubMeshesAsMiscDirty(): void;
  25237. /**
  25238. * Indicates that textures and misc need to be re-calculated for all submeshes
  25239. */
  25240. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  25241. /**
  25242. * Sets the required values to the prepass renderer.
  25243. * @param prePassRenderer defines the prepass renderer to setup.
  25244. * @returns true if the pre pass is needed.
  25245. */
  25246. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  25247. /**
  25248. * Disposes the material
  25249. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25250. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25251. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  25252. */
  25253. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  25254. /** @hidden */
  25255. private releaseVertexArrayObject;
  25256. /**
  25257. * Serializes this material
  25258. * @returns the serialized material object
  25259. */
  25260. serialize(): any;
  25261. /**
  25262. * Creates a material from parsed material data
  25263. * @param parsedMaterial defines parsed material data
  25264. * @param scene defines the hosting scene
  25265. * @param rootUrl defines the root URL to use to load textures
  25266. * @returns a new material
  25267. */
  25268. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  25269. }
  25270. }
  25271. declare module BABYLON {
  25272. /**
  25273. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25274. * separate meshes. This can be use to improve performances.
  25275. * @see https://doc.babylonjs.com/how_to/multi_materials
  25276. */
  25277. export class MultiMaterial extends Material {
  25278. private _subMaterials;
  25279. /**
  25280. * Gets or Sets the list of Materials used within the multi material.
  25281. * They need to be ordered according to the submeshes order in the associated mesh
  25282. */
  25283. get subMaterials(): Nullable<Material>[];
  25284. set subMaterials(value: Nullable<Material>[]);
  25285. /**
  25286. * Function used to align with Node.getChildren()
  25287. * @returns the list of Materials used within the multi material
  25288. */
  25289. getChildren(): Nullable<Material>[];
  25290. /**
  25291. * Instantiates a new Multi Material
  25292. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25293. * separate meshes. This can be use to improve performances.
  25294. * @see https://doc.babylonjs.com/how_to/multi_materials
  25295. * @param name Define the name in the scene
  25296. * @param scene Define the scene the material belongs to
  25297. */
  25298. constructor(name: string, scene: Scene);
  25299. private _hookArray;
  25300. /**
  25301. * Get one of the submaterial by its index in the submaterials array
  25302. * @param index The index to look the sub material at
  25303. * @returns The Material if the index has been defined
  25304. */
  25305. getSubMaterial(index: number): Nullable<Material>;
  25306. /**
  25307. * Get the list of active textures for the whole sub materials list.
  25308. * @returns All the textures that will be used during the rendering
  25309. */
  25310. getActiveTextures(): BaseTexture[];
  25311. /**
  25312. * Gets the current class name of the material e.g. "MultiMaterial"
  25313. * Mainly use in serialization.
  25314. * @returns the class name
  25315. */
  25316. getClassName(): string;
  25317. /**
  25318. * Checks if the material is ready to render the requested sub mesh
  25319. * @param mesh Define the mesh the submesh belongs to
  25320. * @param subMesh Define the sub mesh to look readyness for
  25321. * @param useInstances Define whether or not the material is used with instances
  25322. * @returns true if ready, otherwise false
  25323. */
  25324. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25325. /**
  25326. * Clones the current material and its related sub materials
  25327. * @param name Define the name of the newly cloned material
  25328. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  25329. * @returns the cloned material
  25330. */
  25331. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  25332. /**
  25333. * Serializes the materials into a JSON representation.
  25334. * @returns the JSON representation
  25335. */
  25336. serialize(): any;
  25337. /**
  25338. * Dispose the material and release its associated resources
  25339. * @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)
  25340. * @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)
  25341. * @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)
  25342. */
  25343. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  25344. /**
  25345. * Creates a MultiMaterial from parsed MultiMaterial data.
  25346. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  25347. * @param scene defines the hosting scene
  25348. * @returns a new MultiMaterial
  25349. */
  25350. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  25351. }
  25352. }
  25353. declare module BABYLON {
  25354. /**
  25355. * Defines a subdivision inside a mesh
  25356. */
  25357. export class SubMesh implements ICullable {
  25358. /** the material index to use */
  25359. materialIndex: number;
  25360. /** vertex index start */
  25361. verticesStart: number;
  25362. /** vertices count */
  25363. verticesCount: number;
  25364. /** index start */
  25365. indexStart: number;
  25366. /** indices count */
  25367. indexCount: number;
  25368. /** @hidden */
  25369. _materialDefines: Nullable<MaterialDefines>;
  25370. /** @hidden */
  25371. _materialEffect: Nullable<Effect>;
  25372. /** @hidden */
  25373. _effectOverride: Nullable<Effect>;
  25374. /**
  25375. * Gets material defines used by the effect associated to the sub mesh
  25376. */
  25377. get materialDefines(): Nullable<MaterialDefines>;
  25378. /**
  25379. * Sets material defines used by the effect associated to the sub mesh
  25380. */
  25381. set materialDefines(defines: Nullable<MaterialDefines>);
  25382. /**
  25383. * Gets associated effect
  25384. */
  25385. get effect(): Nullable<Effect>;
  25386. /**
  25387. * Sets associated effect (effect used to render this submesh)
  25388. * @param effect defines the effect to associate with
  25389. * @param defines defines the set of defines used to compile this effect
  25390. */
  25391. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  25392. /** @hidden */
  25393. _linesIndexCount: number;
  25394. private _mesh;
  25395. private _renderingMesh;
  25396. private _boundingInfo;
  25397. private _linesIndexBuffer;
  25398. /** @hidden */
  25399. _lastColliderWorldVertices: Nullable<Vector3[]>;
  25400. /** @hidden */
  25401. _trianglePlanes: Plane[];
  25402. /** @hidden */
  25403. _lastColliderTransformMatrix: Nullable<Matrix>;
  25404. /** @hidden */
  25405. _renderId: number;
  25406. /** @hidden */
  25407. _alphaIndex: number;
  25408. /** @hidden */
  25409. _distanceToCamera: number;
  25410. /** @hidden */
  25411. _id: number;
  25412. private _currentMaterial;
  25413. /**
  25414. * Add a new submesh to a mesh
  25415. * @param materialIndex defines the material index to use
  25416. * @param verticesStart defines vertex index start
  25417. * @param verticesCount defines vertices count
  25418. * @param indexStart defines index start
  25419. * @param indexCount defines indices count
  25420. * @param mesh defines the parent mesh
  25421. * @param renderingMesh defines an optional rendering mesh
  25422. * @param createBoundingBox defines if bounding box should be created for this submesh
  25423. * @returns the new submesh
  25424. */
  25425. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  25426. /**
  25427. * Creates a new submesh
  25428. * @param materialIndex defines the material index to use
  25429. * @param verticesStart defines vertex index start
  25430. * @param verticesCount defines vertices count
  25431. * @param indexStart defines index start
  25432. * @param indexCount defines indices count
  25433. * @param mesh defines the parent mesh
  25434. * @param renderingMesh defines an optional rendering mesh
  25435. * @param createBoundingBox defines if bounding box should be created for this submesh
  25436. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  25437. */
  25438. constructor(
  25439. /** the material index to use */
  25440. materialIndex: number,
  25441. /** vertex index start */
  25442. verticesStart: number,
  25443. /** vertices count */
  25444. verticesCount: number,
  25445. /** index start */
  25446. indexStart: number,
  25447. /** indices count */
  25448. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  25449. /**
  25450. * Returns true if this submesh covers the entire parent mesh
  25451. * @ignorenaming
  25452. */
  25453. get IsGlobal(): boolean;
  25454. /**
  25455. * Returns the submesh BoudingInfo object
  25456. * @returns current bounding info (or mesh's one if the submesh is global)
  25457. */
  25458. getBoundingInfo(): BoundingInfo;
  25459. /**
  25460. * Sets the submesh BoundingInfo
  25461. * @param boundingInfo defines the new bounding info to use
  25462. * @returns the SubMesh
  25463. */
  25464. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  25465. /**
  25466. * Returns the mesh of the current submesh
  25467. * @return the parent mesh
  25468. */
  25469. getMesh(): AbstractMesh;
  25470. /**
  25471. * Returns the rendering mesh of the submesh
  25472. * @returns the rendering mesh (could be different from parent mesh)
  25473. */
  25474. getRenderingMesh(): Mesh;
  25475. /**
  25476. * Returns the replacement mesh of the submesh
  25477. * @returns the replacement mesh (could be different from parent mesh)
  25478. */
  25479. getReplacementMesh(): Nullable<AbstractMesh>;
  25480. /**
  25481. * Returns the effective mesh of the submesh
  25482. * @returns the effective mesh (could be different from parent mesh)
  25483. */
  25484. getEffectiveMesh(): AbstractMesh;
  25485. /**
  25486. * Returns the submesh material
  25487. * @returns null or the current material
  25488. */
  25489. getMaterial(): Nullable<Material>;
  25490. private _IsMultiMaterial;
  25491. /**
  25492. * Sets a new updated BoundingInfo object to the submesh
  25493. * @param data defines an optional position array to use to determine the bounding info
  25494. * @returns the SubMesh
  25495. */
  25496. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  25497. /** @hidden */
  25498. _checkCollision(collider: Collider): boolean;
  25499. /**
  25500. * Updates the submesh BoundingInfo
  25501. * @param world defines the world matrix to use to update the bounding info
  25502. * @returns the submesh
  25503. */
  25504. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  25505. /**
  25506. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  25507. * @param frustumPlanes defines the frustum planes
  25508. * @returns true if the submesh is intersecting with the frustum
  25509. */
  25510. isInFrustum(frustumPlanes: Plane[]): boolean;
  25511. /**
  25512. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  25513. * @param frustumPlanes defines the frustum planes
  25514. * @returns true if the submesh is inside the frustum
  25515. */
  25516. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25517. /**
  25518. * Renders the submesh
  25519. * @param enableAlphaMode defines if alpha needs to be used
  25520. * @returns the submesh
  25521. */
  25522. render(enableAlphaMode: boolean): SubMesh;
  25523. /**
  25524. * @hidden
  25525. */
  25526. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  25527. /**
  25528. * Checks if the submesh intersects with a ray
  25529. * @param ray defines the ray to test
  25530. * @returns true is the passed ray intersects the submesh bounding box
  25531. */
  25532. canIntersects(ray: Ray): boolean;
  25533. /**
  25534. * Intersects current submesh with a ray
  25535. * @param ray defines the ray to test
  25536. * @param positions defines mesh's positions array
  25537. * @param indices defines mesh's indices array
  25538. * @param fastCheck defines if the first intersection will be used (and not the closest)
  25539. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25540. * @returns intersection info or null if no intersection
  25541. */
  25542. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  25543. /** @hidden */
  25544. private _intersectLines;
  25545. /** @hidden */
  25546. private _intersectUnIndexedLines;
  25547. /** @hidden */
  25548. private _intersectTriangles;
  25549. /** @hidden */
  25550. private _intersectUnIndexedTriangles;
  25551. /** @hidden */
  25552. _rebuild(): void;
  25553. /**
  25554. * Creates a new submesh from the passed mesh
  25555. * @param newMesh defines the new hosting mesh
  25556. * @param newRenderingMesh defines an optional rendering mesh
  25557. * @returns the new submesh
  25558. */
  25559. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  25560. /**
  25561. * Release associated resources
  25562. */
  25563. dispose(): void;
  25564. /**
  25565. * Gets the class name
  25566. * @returns the string "SubMesh".
  25567. */
  25568. getClassName(): string;
  25569. /**
  25570. * Creates a new submesh from indices data
  25571. * @param materialIndex the index of the main mesh material
  25572. * @param startIndex the index where to start the copy in the mesh indices array
  25573. * @param indexCount the number of indices to copy then from the startIndex
  25574. * @param mesh the main mesh to create the submesh from
  25575. * @param renderingMesh the optional rendering mesh
  25576. * @returns a new submesh
  25577. */
  25578. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  25579. }
  25580. }
  25581. declare module BABYLON {
  25582. /**
  25583. * Class used to represent data loading progression
  25584. */
  25585. export class SceneLoaderFlags {
  25586. private static _ForceFullSceneLoadingForIncremental;
  25587. private static _ShowLoadingScreen;
  25588. private static _CleanBoneMatrixWeights;
  25589. private static _loggingLevel;
  25590. /**
  25591. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  25592. */
  25593. static get ForceFullSceneLoadingForIncremental(): boolean;
  25594. static set ForceFullSceneLoadingForIncremental(value: boolean);
  25595. /**
  25596. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  25597. */
  25598. static get ShowLoadingScreen(): boolean;
  25599. static set ShowLoadingScreen(value: boolean);
  25600. /**
  25601. * Defines the current logging level (while loading the scene)
  25602. * @ignorenaming
  25603. */
  25604. static get loggingLevel(): number;
  25605. static set loggingLevel(value: number);
  25606. /**
  25607. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  25608. */
  25609. static get CleanBoneMatrixWeights(): boolean;
  25610. static set CleanBoneMatrixWeights(value: boolean);
  25611. }
  25612. }
  25613. declare module BABYLON {
  25614. /**
  25615. * Class used to store geometry data (vertex buffers + index buffer)
  25616. */
  25617. export class Geometry implements IGetSetVerticesData {
  25618. /**
  25619. * Gets or sets the ID of the geometry
  25620. */
  25621. id: string;
  25622. /**
  25623. * Gets or sets the unique ID of the geometry
  25624. */
  25625. uniqueId: number;
  25626. /**
  25627. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25628. */
  25629. delayLoadState: number;
  25630. /**
  25631. * Gets the file containing the data to load when running in delay load state
  25632. */
  25633. delayLoadingFile: Nullable<string>;
  25634. /**
  25635. * Callback called when the geometry is updated
  25636. */
  25637. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25638. private _scene;
  25639. private _engine;
  25640. private _meshes;
  25641. private _totalVertices;
  25642. /** @hidden */
  25643. _indices: IndicesArray;
  25644. /** @hidden */
  25645. _vertexBuffers: {
  25646. [key: string]: VertexBuffer;
  25647. };
  25648. private _isDisposed;
  25649. private _extend;
  25650. private _boundingBias;
  25651. /** @hidden */
  25652. _delayInfo: Array<string>;
  25653. private _indexBuffer;
  25654. private _indexBufferIsUpdatable;
  25655. /** @hidden */
  25656. _boundingInfo: Nullable<BoundingInfo>;
  25657. /** @hidden */
  25658. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25659. /** @hidden */
  25660. _softwareSkinningFrameId: number;
  25661. private _vertexArrayObjects;
  25662. private _updatable;
  25663. /** @hidden */
  25664. _positions: Nullable<Vector3[]>;
  25665. /**
  25666. * 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
  25667. */
  25668. get boundingBias(): Vector2;
  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. set boundingBias(value: Vector2);
  25673. /**
  25674. * Static function used to attach a new empty geometry to a mesh
  25675. * @param mesh defines the mesh to attach the geometry to
  25676. * @returns the new Geometry
  25677. */
  25678. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25679. /** Get the list of meshes using this geometry */
  25680. get meshes(): Mesh[];
  25681. /**
  25682. * 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
  25683. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  25684. */
  25685. useBoundingInfoFromGeometry: boolean;
  25686. /**
  25687. * Creates a new geometry
  25688. * @param id defines the unique ID
  25689. * @param scene defines the hosting scene
  25690. * @param vertexData defines the VertexData used to get geometry data
  25691. * @param updatable defines if geometry must be updatable (false by default)
  25692. * @param mesh defines the mesh that will be associated with the geometry
  25693. */
  25694. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25695. /**
  25696. * Gets the current extend of the geometry
  25697. */
  25698. get extend(): {
  25699. minimum: Vector3;
  25700. maximum: Vector3;
  25701. };
  25702. /**
  25703. * Gets the hosting scene
  25704. * @returns the hosting Scene
  25705. */
  25706. getScene(): Scene;
  25707. /**
  25708. * Gets the hosting engine
  25709. * @returns the hosting Engine
  25710. */
  25711. getEngine(): Engine;
  25712. /**
  25713. * Defines if the geometry is ready to use
  25714. * @returns true if the geometry is ready to be used
  25715. */
  25716. isReady(): boolean;
  25717. /**
  25718. * Gets a value indicating that the geometry should not be serialized
  25719. */
  25720. get doNotSerialize(): boolean;
  25721. /** @hidden */
  25722. _rebuild(): void;
  25723. /**
  25724. * Affects all geometry data in one call
  25725. * @param vertexData defines the geometry data
  25726. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25727. */
  25728. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25729. /**
  25730. * Set specific vertex data
  25731. * @param kind defines the data kind (Position, normal, etc...)
  25732. * @param data defines the vertex data to use
  25733. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25734. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25735. */
  25736. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25737. /**
  25738. * Removes a specific vertex data
  25739. * @param kind defines the data kind (Position, normal, etc...)
  25740. */
  25741. removeVerticesData(kind: string): void;
  25742. /**
  25743. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25744. * @param buffer defines the vertex buffer to use
  25745. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25746. */
  25747. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25748. /**
  25749. * Update a specific vertex buffer
  25750. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  25751. * It will do nothing if the buffer is not updatable
  25752. * @param kind defines the data kind (Position, normal, etc...)
  25753. * @param data defines the data to use
  25754. * @param offset defines the offset in the target buffer where to store the data
  25755. * @param useBytes set to true if the offset is in bytes
  25756. */
  25757. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25758. /**
  25759. * Update a specific vertex buffer
  25760. * This function will create a new buffer if the current one is not updatable
  25761. * @param kind defines the data kind (Position, normal, etc...)
  25762. * @param data defines the data to use
  25763. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25764. */
  25765. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25766. private _updateBoundingInfo;
  25767. /** @hidden */
  25768. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  25769. /**
  25770. * Gets total number of vertices
  25771. * @returns the total number of vertices
  25772. */
  25773. getTotalVertices(): number;
  25774. /**
  25775. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25776. * @param kind defines the data kind (Position, normal, etc...)
  25777. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25778. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25779. * @returns a float array containing vertex data
  25780. */
  25781. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25782. /**
  25783. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25784. * @param kind defines the data kind (Position, normal, etc...)
  25785. * @returns true if the vertex buffer with the specified kind is updatable
  25786. */
  25787. isVertexBufferUpdatable(kind: string): boolean;
  25788. /**
  25789. * Gets a specific vertex buffer
  25790. * @param kind defines the data kind (Position, normal, etc...)
  25791. * @returns a VertexBuffer
  25792. */
  25793. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25794. /**
  25795. * Returns all vertex buffers
  25796. * @return an object holding all vertex buffers indexed by kind
  25797. */
  25798. getVertexBuffers(): Nullable<{
  25799. [key: string]: VertexBuffer;
  25800. }>;
  25801. /**
  25802. * Gets a boolean indicating if specific vertex buffer is present
  25803. * @param kind defines the data kind (Position, normal, etc...)
  25804. * @returns true if data is present
  25805. */
  25806. isVerticesDataPresent(kind: string): boolean;
  25807. /**
  25808. * Gets a list of all attached data kinds (Position, normal, etc...)
  25809. * @returns a list of string containing all kinds
  25810. */
  25811. getVerticesDataKinds(): string[];
  25812. /**
  25813. * Update index buffer
  25814. * @param indices defines the indices to store in the index buffer
  25815. * @param offset defines the offset in the target buffer where to store the data
  25816. * @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)
  25817. */
  25818. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  25819. /**
  25820. * Creates a new index buffer
  25821. * @param indices defines the indices to store in the index buffer
  25822. * @param totalVertices defines the total number of vertices (could be null)
  25823. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25824. */
  25825. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25826. /**
  25827. * Return the total number of indices
  25828. * @returns the total number of indices
  25829. */
  25830. getTotalIndices(): number;
  25831. /**
  25832. * Gets the index buffer array
  25833. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25834. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25835. * @returns the index buffer array
  25836. */
  25837. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25838. /**
  25839. * Gets the index buffer
  25840. * @return the index buffer
  25841. */
  25842. getIndexBuffer(): Nullable<DataBuffer>;
  25843. /** @hidden */
  25844. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25845. /**
  25846. * Release the associated resources for a specific mesh
  25847. * @param mesh defines the source mesh
  25848. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25849. */
  25850. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25851. /**
  25852. * Apply current geometry to a given mesh
  25853. * @param mesh defines the mesh to apply geometry to
  25854. */
  25855. applyToMesh(mesh: Mesh): void;
  25856. private _updateExtend;
  25857. private _applyToMesh;
  25858. private notifyUpdate;
  25859. /**
  25860. * Load the geometry if it was flagged as delay loaded
  25861. * @param scene defines the hosting scene
  25862. * @param onLoaded defines a callback called when the geometry is loaded
  25863. */
  25864. load(scene: Scene, onLoaded?: () => void): void;
  25865. private _queueLoad;
  25866. /**
  25867. * Invert the geometry to move from a right handed system to a left handed one.
  25868. */
  25869. toLeftHanded(): void;
  25870. /** @hidden */
  25871. _resetPointsArrayCache(): void;
  25872. /** @hidden */
  25873. _generatePointsArray(): boolean;
  25874. /**
  25875. * Gets a value indicating if the geometry is disposed
  25876. * @returns true if the geometry was disposed
  25877. */
  25878. isDisposed(): boolean;
  25879. private _disposeVertexArrayObjects;
  25880. /**
  25881. * Free all associated resources
  25882. */
  25883. dispose(): void;
  25884. /**
  25885. * Clone the current geometry into a new geometry
  25886. * @param id defines the unique ID of the new geometry
  25887. * @returns a new geometry object
  25888. */
  25889. copy(id: string): Geometry;
  25890. /**
  25891. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25892. * @return a JSON representation of the current geometry data (without the vertices data)
  25893. */
  25894. serialize(): any;
  25895. private toNumberArray;
  25896. /**
  25897. * Serialize all vertices data into a JSON oject
  25898. * @returns a JSON representation of the current geometry data
  25899. */
  25900. serializeVerticeData(): any;
  25901. /**
  25902. * Extracts a clone of a mesh geometry
  25903. * @param mesh defines the source mesh
  25904. * @param id defines the unique ID of the new geometry object
  25905. * @returns the new geometry object
  25906. */
  25907. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25908. /**
  25909. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25910. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25911. * Be aware Math.random() could cause collisions, but:
  25912. * "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"
  25913. * @returns a string containing a new GUID
  25914. */
  25915. static RandomId(): string;
  25916. /** @hidden */
  25917. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25918. private static _CleanMatricesWeights;
  25919. /**
  25920. * Create a new geometry from persisted data (Using .babylon file format)
  25921. * @param parsedVertexData defines the persisted data
  25922. * @param scene defines the hosting scene
  25923. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25924. * @returns the new geometry object
  25925. */
  25926. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25927. }
  25928. }
  25929. declare module BABYLON {
  25930. /**
  25931. * Define an interface for all classes that will get and set the data on vertices
  25932. */
  25933. export interface IGetSetVerticesData {
  25934. /**
  25935. * Gets a boolean indicating if specific vertex data is present
  25936. * @param kind defines the vertex data kind to use
  25937. * @returns true is data kind is present
  25938. */
  25939. isVerticesDataPresent(kind: string): boolean;
  25940. /**
  25941. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25942. * @param kind defines the data kind (Position, normal, etc...)
  25943. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25944. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25945. * @returns a float array containing vertex data
  25946. */
  25947. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25948. /**
  25949. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25950. * @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.
  25951. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25952. * @returns the indices array or an empty array if the mesh has no geometry
  25953. */
  25954. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25955. /**
  25956. * Set specific vertex data
  25957. * @param kind defines the data kind (Position, normal, etc...)
  25958. * @param data defines the vertex data to use
  25959. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25960. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25961. */
  25962. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  25963. /**
  25964. * Update a specific associated vertex buffer
  25965. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25966. * - VertexBuffer.PositionKind
  25967. * - VertexBuffer.UVKind
  25968. * - VertexBuffer.UV2Kind
  25969. * - VertexBuffer.UV3Kind
  25970. * - VertexBuffer.UV4Kind
  25971. * - VertexBuffer.UV5Kind
  25972. * - VertexBuffer.UV6Kind
  25973. * - VertexBuffer.ColorKind
  25974. * - VertexBuffer.MatricesIndicesKind
  25975. * - VertexBuffer.MatricesIndicesExtraKind
  25976. * - VertexBuffer.MatricesWeightsKind
  25977. * - VertexBuffer.MatricesWeightsExtraKind
  25978. * @param data defines the data source
  25979. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25980. * @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)
  25981. */
  25982. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  25983. /**
  25984. * Creates a new index buffer
  25985. * @param indices defines the indices to store in the index buffer
  25986. * @param totalVertices defines the total number of vertices (could be null)
  25987. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25988. */
  25989. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25990. }
  25991. /**
  25992. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25993. */
  25994. export class VertexData {
  25995. /**
  25996. * Mesh side orientation : usually the external or front surface
  25997. */
  25998. static readonly FRONTSIDE: number;
  25999. /**
  26000. * Mesh side orientation : usually the internal or back surface
  26001. */
  26002. static readonly BACKSIDE: number;
  26003. /**
  26004. * Mesh side orientation : both internal and external or front and back surfaces
  26005. */
  26006. static readonly DOUBLESIDE: number;
  26007. /**
  26008. * Mesh side orientation : by default, `FRONTSIDE`
  26009. */
  26010. static readonly DEFAULTSIDE: number;
  26011. /**
  26012. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  26013. */
  26014. positions: Nullable<FloatArray>;
  26015. /**
  26016. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  26017. */
  26018. normals: Nullable<FloatArray>;
  26019. /**
  26020. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  26021. */
  26022. tangents: Nullable<FloatArray>;
  26023. /**
  26024. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26025. */
  26026. uvs: Nullable<FloatArray>;
  26027. /**
  26028. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26029. */
  26030. uvs2: Nullable<FloatArray>;
  26031. /**
  26032. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26033. */
  26034. uvs3: Nullable<FloatArray>;
  26035. /**
  26036. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26037. */
  26038. uvs4: Nullable<FloatArray>;
  26039. /**
  26040. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26041. */
  26042. uvs5: Nullable<FloatArray>;
  26043. /**
  26044. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26045. */
  26046. uvs6: Nullable<FloatArray>;
  26047. /**
  26048. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  26049. */
  26050. colors: Nullable<FloatArray>;
  26051. /**
  26052. * 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).
  26053. */
  26054. matricesIndices: Nullable<FloatArray>;
  26055. /**
  26056. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  26057. */
  26058. matricesWeights: Nullable<FloatArray>;
  26059. /**
  26060. * An array extending the number of possible indices
  26061. */
  26062. matricesIndicesExtra: Nullable<FloatArray>;
  26063. /**
  26064. * An array extending the number of possible weights when the number of indices is extended
  26065. */
  26066. matricesWeightsExtra: Nullable<FloatArray>;
  26067. /**
  26068. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  26069. */
  26070. indices: Nullable<IndicesArray>;
  26071. /**
  26072. * Uses the passed data array to set the set the values for the specified kind of data
  26073. * @param data a linear array of floating numbers
  26074. * @param kind the type of data that is being set, eg positions, colors etc
  26075. */
  26076. set(data: FloatArray, kind: string): void;
  26077. /**
  26078. * Associates the vertexData to the passed Mesh.
  26079. * Sets it as updatable or not (default `false`)
  26080. * @param mesh the mesh the vertexData is applied to
  26081. * @param updatable when used and having the value true allows new data to update the vertexData
  26082. * @returns the VertexData
  26083. */
  26084. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  26085. /**
  26086. * Associates the vertexData to the passed Geometry.
  26087. * Sets it as updatable or not (default `false`)
  26088. * @param geometry the geometry the vertexData is applied to
  26089. * @param updatable when used and having the value true allows new data to update the vertexData
  26090. * @returns VertexData
  26091. */
  26092. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  26093. /**
  26094. * Updates the associated mesh
  26095. * @param mesh the mesh to be updated
  26096. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26097. * @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
  26098. * @returns VertexData
  26099. */
  26100. updateMesh(mesh: Mesh): VertexData;
  26101. /**
  26102. * Updates the associated geometry
  26103. * @param geometry the geometry to be updated
  26104. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26105. * @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
  26106. * @returns VertexData.
  26107. */
  26108. updateGeometry(geometry: Geometry): VertexData;
  26109. private _applyTo;
  26110. private _update;
  26111. /**
  26112. * Transforms each position and each normal of the vertexData according to the passed Matrix
  26113. * @param matrix the transforming matrix
  26114. * @returns the VertexData
  26115. */
  26116. transform(matrix: Matrix): VertexData;
  26117. /**
  26118. * Merges the passed VertexData into the current one
  26119. * @param other the VertexData to be merged into the current one
  26120. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  26121. * @returns the modified VertexData
  26122. */
  26123. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  26124. private _mergeElement;
  26125. private _validate;
  26126. /**
  26127. * Serializes the VertexData
  26128. * @returns a serialized object
  26129. */
  26130. serialize(): any;
  26131. /**
  26132. * Extracts the vertexData from a mesh
  26133. * @param mesh the mesh from which to extract the VertexData
  26134. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  26135. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26136. * @returns the object VertexData associated to the passed mesh
  26137. */
  26138. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26139. /**
  26140. * Extracts the vertexData from the geometry
  26141. * @param geometry the geometry from which to extract the VertexData
  26142. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  26143. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26144. * @returns the object VertexData associated to the passed mesh
  26145. */
  26146. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26147. private static _ExtractFrom;
  26148. /**
  26149. * Creates the VertexData for a Ribbon
  26150. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  26151. * * pathArray array of paths, each of which an array of successive Vector3
  26152. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  26153. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  26154. * * 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
  26155. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26156. * * 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)
  26157. * * 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)
  26158. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  26159. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  26160. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  26161. * @returns the VertexData of the ribbon
  26162. */
  26163. static CreateRibbon(options: {
  26164. pathArray: Vector3[][];
  26165. closeArray?: boolean;
  26166. closePath?: boolean;
  26167. offset?: number;
  26168. sideOrientation?: number;
  26169. frontUVs?: Vector4;
  26170. backUVs?: Vector4;
  26171. invertUV?: boolean;
  26172. uvs?: Vector2[];
  26173. colors?: Color4[];
  26174. }): VertexData;
  26175. /**
  26176. * Creates the VertexData for a box
  26177. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26178. * * size sets the width, height and depth of the box to the value of size, optional default 1
  26179. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  26180. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  26181. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  26182. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26183. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26184. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26185. * * 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)
  26186. * * 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)
  26187. * @returns the VertexData of the box
  26188. */
  26189. static CreateBox(options: {
  26190. size?: number;
  26191. width?: number;
  26192. height?: number;
  26193. depth?: number;
  26194. faceUV?: Vector4[];
  26195. faceColors?: Color4[];
  26196. sideOrientation?: number;
  26197. frontUVs?: Vector4;
  26198. backUVs?: Vector4;
  26199. }): VertexData;
  26200. /**
  26201. * Creates the VertexData for a tiled box
  26202. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26203. * * faceTiles sets the pattern, tile size and number of tiles for a face
  26204. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26205. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26206. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26207. * @returns the VertexData of the box
  26208. */
  26209. static CreateTiledBox(options: {
  26210. pattern?: number;
  26211. width?: number;
  26212. height?: number;
  26213. depth?: number;
  26214. tileSize?: number;
  26215. tileWidth?: number;
  26216. tileHeight?: number;
  26217. alignHorizontal?: number;
  26218. alignVertical?: number;
  26219. faceUV?: Vector4[];
  26220. faceColors?: Color4[];
  26221. sideOrientation?: number;
  26222. }): VertexData;
  26223. /**
  26224. * Creates the VertexData for a tiled plane
  26225. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26226. * * pattern a limited pattern arrangement depending on the number
  26227. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  26228. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  26229. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  26230. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26231. * * 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)
  26232. * * 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)
  26233. * @returns the VertexData of the tiled plane
  26234. */
  26235. static CreateTiledPlane(options: {
  26236. pattern?: number;
  26237. tileSize?: number;
  26238. tileWidth?: number;
  26239. tileHeight?: number;
  26240. size?: number;
  26241. width?: number;
  26242. height?: number;
  26243. alignHorizontal?: number;
  26244. alignVertical?: number;
  26245. sideOrientation?: number;
  26246. frontUVs?: Vector4;
  26247. backUVs?: Vector4;
  26248. }): VertexData;
  26249. /**
  26250. * Creates the VertexData for an ellipsoid, defaults to a sphere
  26251. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26252. * * segments sets the number of horizontal strips optional, default 32
  26253. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  26254. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  26255. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  26256. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  26257. * * 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
  26258. * * 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
  26259. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26260. * * 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)
  26261. * * 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)
  26262. * @returns the VertexData of the ellipsoid
  26263. */
  26264. static CreateSphere(options: {
  26265. segments?: number;
  26266. diameter?: number;
  26267. diameterX?: number;
  26268. diameterY?: number;
  26269. diameterZ?: number;
  26270. arc?: number;
  26271. slice?: number;
  26272. sideOrientation?: number;
  26273. frontUVs?: Vector4;
  26274. backUVs?: Vector4;
  26275. }): VertexData;
  26276. /**
  26277. * Creates the VertexData for a cylinder, cone or prism
  26278. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26279. * * height sets the height (y direction) of the cylinder, optional, default 2
  26280. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  26281. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  26282. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  26283. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26284. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  26285. * * 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
  26286. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26287. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26288. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  26289. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  26290. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26291. * * 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)
  26292. * * 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)
  26293. * @returns the VertexData of the cylinder, cone or prism
  26294. */
  26295. static CreateCylinder(options: {
  26296. height?: number;
  26297. diameterTop?: number;
  26298. diameterBottom?: number;
  26299. diameter?: number;
  26300. tessellation?: number;
  26301. subdivisions?: number;
  26302. arc?: number;
  26303. faceColors?: Color4[];
  26304. faceUV?: Vector4[];
  26305. hasRings?: boolean;
  26306. enclose?: boolean;
  26307. sideOrientation?: number;
  26308. frontUVs?: Vector4;
  26309. backUVs?: Vector4;
  26310. }): VertexData;
  26311. /**
  26312. * Creates the VertexData for a torus
  26313. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26314. * * diameter the diameter of the torus, optional default 1
  26315. * * thickness the diameter of the tube forming the torus, optional default 0.5
  26316. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26317. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26318. * * 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)
  26319. * * 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)
  26320. * @returns the VertexData of the torus
  26321. */
  26322. static CreateTorus(options: {
  26323. diameter?: number;
  26324. thickness?: number;
  26325. tessellation?: number;
  26326. sideOrientation?: number;
  26327. frontUVs?: Vector4;
  26328. backUVs?: Vector4;
  26329. }): VertexData;
  26330. /**
  26331. * Creates the VertexData of the LineSystem
  26332. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  26333. * - lines an array of lines, each line being an array of successive Vector3
  26334. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  26335. * @returns the VertexData of the LineSystem
  26336. */
  26337. static CreateLineSystem(options: {
  26338. lines: Vector3[][];
  26339. colors?: Nullable<Color4[][]>;
  26340. }): VertexData;
  26341. /**
  26342. * Create the VertexData for a DashedLines
  26343. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  26344. * - points an array successive Vector3
  26345. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  26346. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  26347. * - dashNb the intended total number of dashes, optional, default 200
  26348. * @returns the VertexData for the DashedLines
  26349. */
  26350. static CreateDashedLines(options: {
  26351. points: Vector3[];
  26352. dashSize?: number;
  26353. gapSize?: number;
  26354. dashNb?: number;
  26355. }): VertexData;
  26356. /**
  26357. * Creates the VertexData for a Ground
  26358. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26359. * - width the width (x direction) of the ground, optional, default 1
  26360. * - height the height (z direction) of the ground, optional, default 1
  26361. * - subdivisions the number of subdivisions per side, optional, default 1
  26362. * @returns the VertexData of the Ground
  26363. */
  26364. static CreateGround(options: {
  26365. width?: number;
  26366. height?: number;
  26367. subdivisions?: number;
  26368. subdivisionsX?: number;
  26369. subdivisionsY?: number;
  26370. }): VertexData;
  26371. /**
  26372. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  26373. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26374. * * xmin the ground minimum X coordinate, optional, default -1
  26375. * * zmin the ground minimum Z coordinate, optional, default -1
  26376. * * xmax the ground maximum X coordinate, optional, default 1
  26377. * * zmax the ground maximum Z coordinate, optional, default 1
  26378. * * 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}
  26379. * * 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}
  26380. * @returns the VertexData of the TiledGround
  26381. */
  26382. static CreateTiledGround(options: {
  26383. xmin: number;
  26384. zmin: number;
  26385. xmax: number;
  26386. zmax: number;
  26387. subdivisions?: {
  26388. w: number;
  26389. h: number;
  26390. };
  26391. precision?: {
  26392. w: number;
  26393. h: number;
  26394. };
  26395. }): VertexData;
  26396. /**
  26397. * Creates the VertexData of the Ground designed from a heightmap
  26398. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  26399. * * width the width (x direction) of the ground
  26400. * * height the height (z direction) of the ground
  26401. * * subdivisions the number of subdivisions per side
  26402. * * minHeight the minimum altitude on the ground, optional, default 0
  26403. * * maxHeight the maximum altitude on the ground, optional default 1
  26404. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  26405. * * buffer the array holding the image color data
  26406. * * bufferWidth the width of image
  26407. * * bufferHeight the height of image
  26408. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  26409. * @returns the VertexData of the Ground designed from a heightmap
  26410. */
  26411. static CreateGroundFromHeightMap(options: {
  26412. width: number;
  26413. height: number;
  26414. subdivisions: number;
  26415. minHeight: number;
  26416. maxHeight: number;
  26417. colorFilter: Color3;
  26418. buffer: Uint8Array;
  26419. bufferWidth: number;
  26420. bufferHeight: number;
  26421. alphaFilter: number;
  26422. }): VertexData;
  26423. /**
  26424. * Creates the VertexData for a Plane
  26425. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  26426. * * size sets the width and height of the plane to the value of size, optional default 1
  26427. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  26428. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  26429. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26430. * * 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)
  26431. * * 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)
  26432. * @returns the VertexData of the box
  26433. */
  26434. static CreatePlane(options: {
  26435. size?: number;
  26436. width?: number;
  26437. height?: number;
  26438. sideOrientation?: number;
  26439. frontUVs?: Vector4;
  26440. backUVs?: Vector4;
  26441. }): VertexData;
  26442. /**
  26443. * Creates the VertexData of the Disc or regular Polygon
  26444. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  26445. * * radius the radius of the disc, optional default 0.5
  26446. * * tessellation the number of polygon sides, optional, default 64
  26447. * * 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
  26448. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26449. * * 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)
  26450. * * 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)
  26451. * @returns the VertexData of the box
  26452. */
  26453. static CreateDisc(options: {
  26454. radius?: number;
  26455. tessellation?: number;
  26456. arc?: number;
  26457. sideOrientation?: number;
  26458. frontUVs?: Vector4;
  26459. backUVs?: Vector4;
  26460. }): VertexData;
  26461. /**
  26462. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  26463. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  26464. * @param polygon a mesh built from polygonTriangulation.build()
  26465. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26466. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26467. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26468. * @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)
  26469. * @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)
  26470. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  26471. * @returns the VertexData of the Polygon
  26472. */
  26473. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  26474. /**
  26475. * Creates the VertexData of the IcoSphere
  26476. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  26477. * * radius the radius of the IcoSphere, optional default 1
  26478. * * radiusX allows stretching in the x direction, optional, default radius
  26479. * * radiusY allows stretching in the y direction, optional, default radius
  26480. * * radiusZ allows stretching in the z direction, optional, default radius
  26481. * * flat when true creates a flat shaded mesh, optional, default true
  26482. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26483. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26484. * * 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)
  26485. * * 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)
  26486. * @returns the VertexData of the IcoSphere
  26487. */
  26488. static CreateIcoSphere(options: {
  26489. radius?: number;
  26490. radiusX?: number;
  26491. radiusY?: number;
  26492. radiusZ?: number;
  26493. flat?: boolean;
  26494. subdivisions?: number;
  26495. sideOrientation?: number;
  26496. frontUVs?: Vector4;
  26497. backUVs?: Vector4;
  26498. }): VertexData;
  26499. /**
  26500. * Creates the VertexData for a Polyhedron
  26501. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  26502. * * type provided types are:
  26503. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  26504. * * 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)
  26505. * * size the size of the IcoSphere, optional default 1
  26506. * * sizeX allows stretching in the x direction, optional, default size
  26507. * * sizeY allows stretching in the y direction, optional, default size
  26508. * * sizeZ allows stretching in the z direction, optional, default size
  26509. * * 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
  26510. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26511. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26512. * * flat when true creates a flat shaded mesh, optional, default true
  26513. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26514. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26515. * * 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)
  26516. * * 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)
  26517. * @returns the VertexData of the Polyhedron
  26518. */
  26519. static CreatePolyhedron(options: {
  26520. type?: number;
  26521. size?: number;
  26522. sizeX?: number;
  26523. sizeY?: number;
  26524. sizeZ?: number;
  26525. custom?: any;
  26526. faceUV?: Vector4[];
  26527. faceColors?: Color4[];
  26528. flat?: boolean;
  26529. sideOrientation?: number;
  26530. frontUVs?: Vector4;
  26531. backUVs?: Vector4;
  26532. }): VertexData;
  26533. /**
  26534. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  26535. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  26536. * @returns the VertexData of the Capsule
  26537. */
  26538. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  26539. /**
  26540. * Creates the VertexData for a TorusKnot
  26541. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  26542. * * radius the radius of the torus knot, optional, default 2
  26543. * * tube the thickness of the tube, optional, default 0.5
  26544. * * radialSegments the number of sides on each tube segments, optional, default 32
  26545. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  26546. * * p the number of windings around the z axis, optional, default 2
  26547. * * q the number of windings around the x axis, optional, default 3
  26548. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26549. * * 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)
  26550. * * 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)
  26551. * @returns the VertexData of the Torus Knot
  26552. */
  26553. static CreateTorusKnot(options: {
  26554. radius?: number;
  26555. tube?: number;
  26556. radialSegments?: number;
  26557. tubularSegments?: number;
  26558. p?: number;
  26559. q?: number;
  26560. sideOrientation?: number;
  26561. frontUVs?: Vector4;
  26562. backUVs?: Vector4;
  26563. }): VertexData;
  26564. /**
  26565. * Compute normals for given positions and indices
  26566. * @param positions an array of vertex positions, [...., x, y, z, ......]
  26567. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  26568. * @param normals an array of vertex normals, [...., x, y, z, ......]
  26569. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  26570. * * facetNormals : optional array of facet normals (vector3)
  26571. * * facetPositions : optional array of facet positions (vector3)
  26572. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  26573. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  26574. * * bInfo : optional bounding info, required for facetPartitioning computation
  26575. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  26576. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  26577. * * useRightHandedSystem: optional boolean to for right handed system computation
  26578. * * depthSort : optional boolean to enable the facet depth sort computation
  26579. * * distanceTo : optional Vector3 to compute the facet depth from this location
  26580. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  26581. */
  26582. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  26583. facetNormals?: any;
  26584. facetPositions?: any;
  26585. facetPartitioning?: any;
  26586. ratio?: number;
  26587. bInfo?: any;
  26588. bbSize?: Vector3;
  26589. subDiv?: any;
  26590. useRightHandedSystem?: boolean;
  26591. depthSort?: boolean;
  26592. distanceTo?: Vector3;
  26593. depthSortedFacets?: any;
  26594. }): void;
  26595. /** @hidden */
  26596. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  26597. /**
  26598. * Applies VertexData created from the imported parameters to the geometry
  26599. * @param parsedVertexData the parsed data from an imported file
  26600. * @param geometry the geometry to apply the VertexData to
  26601. */
  26602. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  26603. }
  26604. }
  26605. declare module BABYLON {
  26606. /**
  26607. * Defines a target to use with MorphTargetManager
  26608. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26609. */
  26610. export class MorphTarget implements IAnimatable {
  26611. /** defines the name of the target */
  26612. name: string;
  26613. /**
  26614. * Gets or sets the list of animations
  26615. */
  26616. animations: Animation[];
  26617. private _scene;
  26618. private _positions;
  26619. private _normals;
  26620. private _tangents;
  26621. private _uvs;
  26622. private _influence;
  26623. private _uniqueId;
  26624. /**
  26625. * Observable raised when the influence changes
  26626. */
  26627. onInfluenceChanged: Observable<boolean>;
  26628. /** @hidden */
  26629. _onDataLayoutChanged: Observable<void>;
  26630. /**
  26631. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  26632. */
  26633. get influence(): number;
  26634. set influence(influence: number);
  26635. /**
  26636. * Gets or sets the id of the morph Target
  26637. */
  26638. id: string;
  26639. private _animationPropertiesOverride;
  26640. /**
  26641. * Gets or sets the animation properties override
  26642. */
  26643. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26644. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26645. /**
  26646. * Creates a new MorphTarget
  26647. * @param name defines the name of the target
  26648. * @param influence defines the influence to use
  26649. * @param scene defines the scene the morphtarget belongs to
  26650. */
  26651. constructor(
  26652. /** defines the name of the target */
  26653. name: string, influence?: number, scene?: Nullable<Scene>);
  26654. /**
  26655. * Gets the unique ID of this manager
  26656. */
  26657. get uniqueId(): number;
  26658. /**
  26659. * Gets a boolean defining if the target contains position data
  26660. */
  26661. get hasPositions(): boolean;
  26662. /**
  26663. * Gets a boolean defining if the target contains normal data
  26664. */
  26665. get hasNormals(): boolean;
  26666. /**
  26667. * Gets a boolean defining if the target contains tangent data
  26668. */
  26669. get hasTangents(): boolean;
  26670. /**
  26671. * Gets a boolean defining if the target contains texture coordinates data
  26672. */
  26673. get hasUVs(): boolean;
  26674. /**
  26675. * Affects position data to this target
  26676. * @param data defines the position data to use
  26677. */
  26678. setPositions(data: Nullable<FloatArray>): void;
  26679. /**
  26680. * Gets the position data stored in this target
  26681. * @returns a FloatArray containing the position data (or null if not present)
  26682. */
  26683. getPositions(): Nullable<FloatArray>;
  26684. /**
  26685. * Affects normal data to this target
  26686. * @param data defines the normal data to use
  26687. */
  26688. setNormals(data: Nullable<FloatArray>): void;
  26689. /**
  26690. * Gets the normal data stored in this target
  26691. * @returns a FloatArray containing the normal data (or null if not present)
  26692. */
  26693. getNormals(): Nullable<FloatArray>;
  26694. /**
  26695. * Affects tangent data to this target
  26696. * @param data defines the tangent data to use
  26697. */
  26698. setTangents(data: Nullable<FloatArray>): void;
  26699. /**
  26700. * Gets the tangent data stored in this target
  26701. * @returns a FloatArray containing the tangent data (or null if not present)
  26702. */
  26703. getTangents(): Nullable<FloatArray>;
  26704. /**
  26705. * Affects texture coordinates data to this target
  26706. * @param data defines the texture coordinates data to use
  26707. */
  26708. setUVs(data: Nullable<FloatArray>): void;
  26709. /**
  26710. * Gets the texture coordinates data stored in this target
  26711. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  26712. */
  26713. getUVs(): Nullable<FloatArray>;
  26714. /**
  26715. * Clone the current target
  26716. * @returns a new MorphTarget
  26717. */
  26718. clone(): MorphTarget;
  26719. /**
  26720. * Serializes the current target into a Serialization object
  26721. * @returns the serialized object
  26722. */
  26723. serialize(): any;
  26724. /**
  26725. * Returns the string "MorphTarget"
  26726. * @returns "MorphTarget"
  26727. */
  26728. getClassName(): string;
  26729. /**
  26730. * Creates a new target from serialized data
  26731. * @param serializationObject defines the serialized data to use
  26732. * @returns a new MorphTarget
  26733. */
  26734. static Parse(serializationObject: any): MorphTarget;
  26735. /**
  26736. * Creates a MorphTarget from mesh data
  26737. * @param mesh defines the source mesh
  26738. * @param name defines the name to use for the new target
  26739. * @param influence defines the influence to attach to the target
  26740. * @returns a new MorphTarget
  26741. */
  26742. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  26743. }
  26744. }
  26745. declare module BABYLON {
  26746. /**
  26747. * This class is used to deform meshes using morphing between different targets
  26748. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26749. */
  26750. export class MorphTargetManager {
  26751. private _targets;
  26752. private _targetInfluenceChangedObservers;
  26753. private _targetDataLayoutChangedObservers;
  26754. private _activeTargets;
  26755. private _scene;
  26756. private _influences;
  26757. private _supportsNormals;
  26758. private _supportsTangents;
  26759. private _supportsUVs;
  26760. private _vertexCount;
  26761. private _uniqueId;
  26762. private _tempInfluences;
  26763. /**
  26764. * Gets or sets a boolean indicating if normals must be morphed
  26765. */
  26766. enableNormalMorphing: boolean;
  26767. /**
  26768. * Gets or sets a boolean indicating if tangents must be morphed
  26769. */
  26770. enableTangentMorphing: boolean;
  26771. /**
  26772. * Gets or sets a boolean indicating if UV must be morphed
  26773. */
  26774. enableUVMorphing: boolean;
  26775. /**
  26776. * Creates a new MorphTargetManager
  26777. * @param scene defines the current scene
  26778. */
  26779. constructor(scene?: Nullable<Scene>);
  26780. /**
  26781. * Gets the unique ID of this manager
  26782. */
  26783. get uniqueId(): number;
  26784. /**
  26785. * Gets the number of vertices handled by this manager
  26786. */
  26787. get vertexCount(): number;
  26788. /**
  26789. * Gets a boolean indicating if this manager supports morphing of normals
  26790. */
  26791. get supportsNormals(): boolean;
  26792. /**
  26793. * Gets a boolean indicating if this manager supports morphing of tangents
  26794. */
  26795. get supportsTangents(): boolean;
  26796. /**
  26797. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  26798. */
  26799. get supportsUVs(): boolean;
  26800. /**
  26801. * Gets the number of targets stored in this manager
  26802. */
  26803. get numTargets(): number;
  26804. /**
  26805. * Gets the number of influencers (ie. the number of targets with influences > 0)
  26806. */
  26807. get numInfluencers(): number;
  26808. /**
  26809. * Gets the list of influences (one per target)
  26810. */
  26811. get influences(): Float32Array;
  26812. /**
  26813. * Gets the active target at specified index. An active target is a target with an influence > 0
  26814. * @param index defines the index to check
  26815. * @returns the requested target
  26816. */
  26817. getActiveTarget(index: number): MorphTarget;
  26818. /**
  26819. * Gets the target at specified index
  26820. * @param index defines the index to check
  26821. * @returns the requested target
  26822. */
  26823. getTarget(index: number): MorphTarget;
  26824. /**
  26825. * Add a new target to this manager
  26826. * @param target defines the target to add
  26827. */
  26828. addTarget(target: MorphTarget): void;
  26829. /**
  26830. * Removes a target from the manager
  26831. * @param target defines the target to remove
  26832. */
  26833. removeTarget(target: MorphTarget): void;
  26834. /**
  26835. * Clone the current manager
  26836. * @returns a new MorphTargetManager
  26837. */
  26838. clone(): MorphTargetManager;
  26839. /**
  26840. * Serializes the current manager into a Serialization object
  26841. * @returns the serialized object
  26842. */
  26843. serialize(): any;
  26844. private _syncActiveTargets;
  26845. /**
  26846. * Syncrhonize the targets with all the meshes using this morph target manager
  26847. */
  26848. synchronize(): void;
  26849. /**
  26850. * Creates a new MorphTargetManager from serialized data
  26851. * @param serializationObject defines the serialized data
  26852. * @param scene defines the hosting scene
  26853. * @returns the new MorphTargetManager
  26854. */
  26855. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  26856. }
  26857. }
  26858. declare module BABYLON {
  26859. /**
  26860. * Class used to represent a specific level of detail of a mesh
  26861. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26862. */
  26863. export class MeshLODLevel {
  26864. /** Defines the distance where this level should start being displayed */
  26865. distance: number;
  26866. /** Defines the mesh to use to render this level */
  26867. mesh: Nullable<Mesh>;
  26868. /**
  26869. * Creates a new LOD level
  26870. * @param distance defines the distance where this level should star being displayed
  26871. * @param mesh defines the mesh to use to render this level
  26872. */
  26873. constructor(
  26874. /** Defines the distance where this level should start being displayed */
  26875. distance: number,
  26876. /** Defines the mesh to use to render this level */
  26877. mesh: Nullable<Mesh>);
  26878. }
  26879. }
  26880. declare module BABYLON {
  26881. /**
  26882. * Helper class used to generate a canvas to manipulate images
  26883. */
  26884. export class CanvasGenerator {
  26885. /**
  26886. * Create a new canvas (or offscreen canvas depending on the context)
  26887. * @param width defines the expected width
  26888. * @param height defines the expected height
  26889. * @return a new canvas or offscreen canvas
  26890. */
  26891. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  26892. }
  26893. }
  26894. declare module BABYLON {
  26895. /**
  26896. * Mesh representing the gorund
  26897. */
  26898. export class GroundMesh extends Mesh {
  26899. /** If octree should be generated */
  26900. generateOctree: boolean;
  26901. private _heightQuads;
  26902. /** @hidden */
  26903. _subdivisionsX: number;
  26904. /** @hidden */
  26905. _subdivisionsY: number;
  26906. /** @hidden */
  26907. _width: number;
  26908. /** @hidden */
  26909. _height: number;
  26910. /** @hidden */
  26911. _minX: number;
  26912. /** @hidden */
  26913. _maxX: number;
  26914. /** @hidden */
  26915. _minZ: number;
  26916. /** @hidden */
  26917. _maxZ: number;
  26918. constructor(name: string, scene: Scene);
  26919. /**
  26920. * "GroundMesh"
  26921. * @returns "GroundMesh"
  26922. */
  26923. getClassName(): string;
  26924. /**
  26925. * The minimum of x and y subdivisions
  26926. */
  26927. get subdivisions(): number;
  26928. /**
  26929. * X subdivisions
  26930. */
  26931. get subdivisionsX(): number;
  26932. /**
  26933. * Y subdivisions
  26934. */
  26935. get subdivisionsY(): number;
  26936. /**
  26937. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26938. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26939. * @param chunksCount the number of subdivisions for x and y
  26940. * @param octreeBlocksSize (Default: 32)
  26941. */
  26942. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26943. /**
  26944. * Returns a height (y) value in the Worl system :
  26945. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26946. * @param x x coordinate
  26947. * @param z z coordinate
  26948. * @returns the ground y position if (x, z) are outside the ground surface.
  26949. */
  26950. getHeightAtCoordinates(x: number, z: number): number;
  26951. /**
  26952. * Returns a normalized vector (Vector3) orthogonal to the ground
  26953. * at the ground coordinates (x, z) expressed in the World system.
  26954. * @param x x coordinate
  26955. * @param z z coordinate
  26956. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26957. */
  26958. getNormalAtCoordinates(x: number, z: number): Vector3;
  26959. /**
  26960. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26961. * at the ground coordinates (x, z) expressed in the World system.
  26962. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26963. * @param x x coordinate
  26964. * @param z z coordinate
  26965. * @param ref vector to store the result
  26966. * @returns the GroundMesh.
  26967. */
  26968. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26969. /**
  26970. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26971. * if the ground has been updated.
  26972. * This can be used in the render loop.
  26973. * @returns the GroundMesh.
  26974. */
  26975. updateCoordinateHeights(): GroundMesh;
  26976. private _getFacetAt;
  26977. private _initHeightQuads;
  26978. private _computeHeightQuads;
  26979. /**
  26980. * Serializes this ground mesh
  26981. * @param serializationObject object to write serialization to
  26982. */
  26983. serialize(serializationObject: any): void;
  26984. /**
  26985. * Parses a serialized ground mesh
  26986. * @param parsedMesh the serialized mesh
  26987. * @param scene the scene to create the ground mesh in
  26988. * @returns the created ground mesh
  26989. */
  26990. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26991. }
  26992. }
  26993. declare module BABYLON {
  26994. /**
  26995. * Interface for Physics-Joint data
  26996. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26997. */
  26998. export interface PhysicsJointData {
  26999. /**
  27000. * The main pivot of the joint
  27001. */
  27002. mainPivot?: Vector3;
  27003. /**
  27004. * The connected pivot of the joint
  27005. */
  27006. connectedPivot?: Vector3;
  27007. /**
  27008. * The main axis of the joint
  27009. */
  27010. mainAxis?: Vector3;
  27011. /**
  27012. * The connected axis of the joint
  27013. */
  27014. connectedAxis?: Vector3;
  27015. /**
  27016. * The collision of the joint
  27017. */
  27018. collision?: boolean;
  27019. /**
  27020. * Native Oimo/Cannon/Energy data
  27021. */
  27022. nativeParams?: any;
  27023. }
  27024. /**
  27025. * This is a holder class for the physics joint created by the physics plugin
  27026. * It holds a set of functions to control the underlying joint
  27027. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27028. */
  27029. export class PhysicsJoint {
  27030. /**
  27031. * The type of the physics joint
  27032. */
  27033. type: number;
  27034. /**
  27035. * The data for the physics joint
  27036. */
  27037. jointData: PhysicsJointData;
  27038. private _physicsJoint;
  27039. protected _physicsPlugin: IPhysicsEnginePlugin;
  27040. /**
  27041. * Initializes the physics joint
  27042. * @param type The type of the physics joint
  27043. * @param jointData The data for the physics joint
  27044. */
  27045. constructor(
  27046. /**
  27047. * The type of the physics joint
  27048. */
  27049. type: number,
  27050. /**
  27051. * The data for the physics joint
  27052. */
  27053. jointData: PhysicsJointData);
  27054. /**
  27055. * Gets the physics joint
  27056. */
  27057. get physicsJoint(): any;
  27058. /**
  27059. * Sets the physics joint
  27060. */
  27061. set physicsJoint(newJoint: any);
  27062. /**
  27063. * Sets the physics plugin
  27064. */
  27065. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  27066. /**
  27067. * Execute a function that is physics-plugin specific.
  27068. * @param {Function} func the function that will be executed.
  27069. * It accepts two parameters: the physics world and the physics joint
  27070. */
  27071. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  27072. /**
  27073. * Distance-Joint type
  27074. */
  27075. static DistanceJoint: number;
  27076. /**
  27077. * Hinge-Joint type
  27078. */
  27079. static HingeJoint: number;
  27080. /**
  27081. * Ball-and-Socket joint type
  27082. */
  27083. static BallAndSocketJoint: number;
  27084. /**
  27085. * Wheel-Joint type
  27086. */
  27087. static WheelJoint: number;
  27088. /**
  27089. * Slider-Joint type
  27090. */
  27091. static SliderJoint: number;
  27092. /**
  27093. * Prismatic-Joint type
  27094. */
  27095. static PrismaticJoint: number;
  27096. /**
  27097. * Universal-Joint type
  27098. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  27099. */
  27100. static UniversalJoint: number;
  27101. /**
  27102. * Hinge-Joint 2 type
  27103. */
  27104. static Hinge2Joint: number;
  27105. /**
  27106. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  27107. */
  27108. static PointToPointJoint: number;
  27109. /**
  27110. * Spring-Joint type
  27111. */
  27112. static SpringJoint: number;
  27113. /**
  27114. * Lock-Joint type
  27115. */
  27116. static LockJoint: number;
  27117. }
  27118. /**
  27119. * A class representing a physics distance joint
  27120. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27121. */
  27122. export class DistanceJoint extends PhysicsJoint {
  27123. /**
  27124. *
  27125. * @param jointData The data for the Distance-Joint
  27126. */
  27127. constructor(jointData: DistanceJointData);
  27128. /**
  27129. * Update the predefined distance.
  27130. * @param maxDistance The maximum preferred distance
  27131. * @param minDistance The minimum preferred distance
  27132. */
  27133. updateDistance(maxDistance: number, minDistance?: number): void;
  27134. }
  27135. /**
  27136. * Represents a Motor-Enabled Joint
  27137. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27138. */
  27139. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  27140. /**
  27141. * Initializes the Motor-Enabled Joint
  27142. * @param type The type of the joint
  27143. * @param jointData The physica joint data for the joint
  27144. */
  27145. constructor(type: number, jointData: PhysicsJointData);
  27146. /**
  27147. * Set the motor values.
  27148. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27149. * @param force the force to apply
  27150. * @param maxForce max force for this motor.
  27151. */
  27152. setMotor(force?: number, maxForce?: number): void;
  27153. /**
  27154. * Set the motor's limits.
  27155. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27156. * @param upperLimit The upper limit of the motor
  27157. * @param lowerLimit The lower limit of the motor
  27158. */
  27159. setLimit(upperLimit: number, lowerLimit?: number): void;
  27160. }
  27161. /**
  27162. * This class represents a single physics Hinge-Joint
  27163. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27164. */
  27165. export class HingeJoint extends MotorEnabledJoint {
  27166. /**
  27167. * Initializes the Hinge-Joint
  27168. * @param jointData The joint data for the Hinge-Joint
  27169. */
  27170. constructor(jointData: PhysicsJointData);
  27171. /**
  27172. * Set the motor values.
  27173. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27174. * @param {number} force the force to apply
  27175. * @param {number} maxForce max force for this motor.
  27176. */
  27177. setMotor(force?: number, maxForce?: number): void;
  27178. /**
  27179. * Set the motor's limits.
  27180. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27181. * @param upperLimit The upper limit of the motor
  27182. * @param lowerLimit The lower limit of the motor
  27183. */
  27184. setLimit(upperLimit: number, lowerLimit?: number): void;
  27185. }
  27186. /**
  27187. * This class represents a dual hinge physics joint (same as wheel joint)
  27188. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27189. */
  27190. export class Hinge2Joint extends MotorEnabledJoint {
  27191. /**
  27192. * Initializes the Hinge2-Joint
  27193. * @param jointData The joint data for the Hinge2-Joint
  27194. */
  27195. constructor(jointData: PhysicsJointData);
  27196. /**
  27197. * Set the motor values.
  27198. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27199. * @param {number} targetSpeed the speed the motor is to reach
  27200. * @param {number} maxForce max force for this motor.
  27201. * @param {motorIndex} the motor's index, 0 or 1.
  27202. */
  27203. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  27204. /**
  27205. * Set the motor limits.
  27206. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27207. * @param {number} upperLimit the upper limit
  27208. * @param {number} lowerLimit lower limit
  27209. * @param {motorIndex} the motor's index, 0 or 1.
  27210. */
  27211. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27212. }
  27213. /**
  27214. * Interface for a motor enabled joint
  27215. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27216. */
  27217. export interface IMotorEnabledJoint {
  27218. /**
  27219. * Physics joint
  27220. */
  27221. physicsJoint: any;
  27222. /**
  27223. * Sets the motor of the motor-enabled joint
  27224. * @param force The force of the motor
  27225. * @param maxForce The maximum force of the motor
  27226. * @param motorIndex The index of the motor
  27227. */
  27228. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27229. /**
  27230. * Sets the limit of the motor
  27231. * @param upperLimit The upper limit of the motor
  27232. * @param lowerLimit The lower limit of the motor
  27233. * @param motorIndex The index of the motor
  27234. */
  27235. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27236. }
  27237. /**
  27238. * Joint data for a Distance-Joint
  27239. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27240. */
  27241. export interface DistanceJointData extends PhysicsJointData {
  27242. /**
  27243. * Max distance the 2 joint objects can be apart
  27244. */
  27245. maxDistance: number;
  27246. }
  27247. /**
  27248. * Joint data from a spring joint
  27249. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27250. */
  27251. export interface SpringJointData extends PhysicsJointData {
  27252. /**
  27253. * Length of the spring
  27254. */
  27255. length: number;
  27256. /**
  27257. * Stiffness of the spring
  27258. */
  27259. stiffness: number;
  27260. /**
  27261. * Damping of the spring
  27262. */
  27263. damping: number;
  27264. /** this callback will be called when applying the force to the impostors. */
  27265. forceApplicationCallback: () => void;
  27266. }
  27267. }
  27268. declare module BABYLON {
  27269. /**
  27270. * Holds the data for the raycast result
  27271. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27272. */
  27273. export class PhysicsRaycastResult {
  27274. private _hasHit;
  27275. private _hitDistance;
  27276. private _hitNormalWorld;
  27277. private _hitPointWorld;
  27278. private _rayFromWorld;
  27279. private _rayToWorld;
  27280. /**
  27281. * Gets if there was a hit
  27282. */
  27283. get hasHit(): boolean;
  27284. /**
  27285. * Gets the distance from the hit
  27286. */
  27287. get hitDistance(): number;
  27288. /**
  27289. * Gets the hit normal/direction in the world
  27290. */
  27291. get hitNormalWorld(): Vector3;
  27292. /**
  27293. * Gets the hit point in the world
  27294. */
  27295. get hitPointWorld(): Vector3;
  27296. /**
  27297. * Gets the ray "start point" of the ray in the world
  27298. */
  27299. get rayFromWorld(): Vector3;
  27300. /**
  27301. * Gets the ray "end point" of the ray in the world
  27302. */
  27303. get rayToWorld(): Vector3;
  27304. /**
  27305. * Sets the hit data (normal & point in world space)
  27306. * @param hitNormalWorld defines the normal in world space
  27307. * @param hitPointWorld defines the point in world space
  27308. */
  27309. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  27310. /**
  27311. * Sets the distance from the start point to the hit point
  27312. * @param distance
  27313. */
  27314. setHitDistance(distance: number): void;
  27315. /**
  27316. * Calculates the distance manually
  27317. */
  27318. calculateHitDistance(): void;
  27319. /**
  27320. * Resets all the values to default
  27321. * @param from The from point on world space
  27322. * @param to The to point on world space
  27323. */
  27324. reset(from?: Vector3, to?: Vector3): void;
  27325. }
  27326. /**
  27327. * Interface for the size containing width and height
  27328. */
  27329. interface IXYZ {
  27330. /**
  27331. * X
  27332. */
  27333. x: number;
  27334. /**
  27335. * Y
  27336. */
  27337. y: number;
  27338. /**
  27339. * Z
  27340. */
  27341. z: number;
  27342. }
  27343. }
  27344. declare module BABYLON {
  27345. /**
  27346. * Interface used to describe a physics joint
  27347. */
  27348. export interface PhysicsImpostorJoint {
  27349. /** Defines the main impostor to which the joint is linked */
  27350. mainImpostor: PhysicsImpostor;
  27351. /** Defines the impostor that is connected to the main impostor using this joint */
  27352. connectedImpostor: PhysicsImpostor;
  27353. /** Defines the joint itself */
  27354. joint: PhysicsJoint;
  27355. }
  27356. /** @hidden */
  27357. export interface IPhysicsEnginePlugin {
  27358. world: any;
  27359. name: string;
  27360. setGravity(gravity: Vector3): void;
  27361. setTimeStep(timeStep: number): void;
  27362. getTimeStep(): number;
  27363. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  27364. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27365. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27366. generatePhysicsBody(impostor: PhysicsImpostor): void;
  27367. removePhysicsBody(impostor: PhysicsImpostor): void;
  27368. generateJoint(joint: PhysicsImpostorJoint): void;
  27369. removeJoint(joint: PhysicsImpostorJoint): void;
  27370. isSupported(): boolean;
  27371. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  27372. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  27373. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27374. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27375. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27376. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27377. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  27378. getBodyMass(impostor: PhysicsImpostor): number;
  27379. getBodyFriction(impostor: PhysicsImpostor): number;
  27380. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  27381. getBodyRestitution(impostor: PhysicsImpostor): number;
  27382. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  27383. getBodyPressure?(impostor: PhysicsImpostor): number;
  27384. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  27385. getBodyStiffness?(impostor: PhysicsImpostor): number;
  27386. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  27387. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  27388. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  27389. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  27390. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  27391. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27392. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27393. sleepBody(impostor: PhysicsImpostor): void;
  27394. wakeUpBody(impostor: PhysicsImpostor): void;
  27395. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27396. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  27397. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  27398. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27399. getRadius(impostor: PhysicsImpostor): number;
  27400. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  27401. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  27402. dispose(): void;
  27403. }
  27404. /**
  27405. * Interface used to define a physics engine
  27406. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27407. */
  27408. export interface IPhysicsEngine {
  27409. /**
  27410. * Gets the gravity vector used by the simulation
  27411. */
  27412. gravity: Vector3;
  27413. /**
  27414. * Sets the gravity vector used by the simulation
  27415. * @param gravity defines the gravity vector to use
  27416. */
  27417. setGravity(gravity: Vector3): void;
  27418. /**
  27419. * Set the time step of the physics engine.
  27420. * Default is 1/60.
  27421. * To slow it down, enter 1/600 for example.
  27422. * To speed it up, 1/30
  27423. * @param newTimeStep the new timestep to apply to this world.
  27424. */
  27425. setTimeStep(newTimeStep: number): void;
  27426. /**
  27427. * Get the time step of the physics engine.
  27428. * @returns the current time step
  27429. */
  27430. getTimeStep(): number;
  27431. /**
  27432. * Set the sub time step of the physics engine.
  27433. * Default is 0 meaning there is no sub steps
  27434. * To increase physics resolution precision, set a small value (like 1 ms)
  27435. * @param subTimeStep defines the new sub timestep used for physics resolution.
  27436. */
  27437. setSubTimeStep(subTimeStep: number): void;
  27438. /**
  27439. * Get the sub time step of the physics engine.
  27440. * @returns the current sub time step
  27441. */
  27442. getSubTimeStep(): number;
  27443. /**
  27444. * Release all resources
  27445. */
  27446. dispose(): void;
  27447. /**
  27448. * Gets the name of the current physics plugin
  27449. * @returns the name of the plugin
  27450. */
  27451. getPhysicsPluginName(): string;
  27452. /**
  27453. * Adding a new impostor for the impostor tracking.
  27454. * This will be done by the impostor itself.
  27455. * @param impostor the impostor to add
  27456. */
  27457. addImpostor(impostor: PhysicsImpostor): void;
  27458. /**
  27459. * Remove an impostor from the engine.
  27460. * This impostor and its mesh will not longer be updated by the physics engine.
  27461. * @param impostor the impostor to remove
  27462. */
  27463. removeImpostor(impostor: PhysicsImpostor): void;
  27464. /**
  27465. * Add a joint to the physics engine
  27466. * @param mainImpostor defines the main impostor to which the joint is added.
  27467. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  27468. * @param joint defines the joint that will connect both impostors.
  27469. */
  27470. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27471. /**
  27472. * Removes a joint from the simulation
  27473. * @param mainImpostor defines the impostor used with the joint
  27474. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  27475. * @param joint defines the joint to remove
  27476. */
  27477. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27478. /**
  27479. * Gets the current plugin used to run the simulation
  27480. * @returns current plugin
  27481. */
  27482. getPhysicsPlugin(): IPhysicsEnginePlugin;
  27483. /**
  27484. * Gets the list of physic impostors
  27485. * @returns an array of PhysicsImpostor
  27486. */
  27487. getImpostors(): Array<PhysicsImpostor>;
  27488. /**
  27489. * Gets the impostor for a physics enabled object
  27490. * @param object defines the object impersonated by the impostor
  27491. * @returns the PhysicsImpostor or null if not found
  27492. */
  27493. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27494. /**
  27495. * Gets the impostor for a physics body object
  27496. * @param body defines physics body used by the impostor
  27497. * @returns the PhysicsImpostor or null if not found
  27498. */
  27499. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  27500. /**
  27501. * Does a raycast in the physics world
  27502. * @param from when should the ray start?
  27503. * @param to when should the ray end?
  27504. * @returns PhysicsRaycastResult
  27505. */
  27506. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27507. /**
  27508. * Called by the scene. No need to call it.
  27509. * @param delta defines the timespam between frames
  27510. */
  27511. _step(delta: number): void;
  27512. }
  27513. }
  27514. declare module BABYLON {
  27515. /**
  27516. * The interface for the physics imposter parameters
  27517. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27518. */
  27519. export interface PhysicsImpostorParameters {
  27520. /**
  27521. * The mass of the physics imposter
  27522. */
  27523. mass: number;
  27524. /**
  27525. * The friction of the physics imposter
  27526. */
  27527. friction?: number;
  27528. /**
  27529. * The coefficient of restitution of the physics imposter
  27530. */
  27531. restitution?: number;
  27532. /**
  27533. * The native options of the physics imposter
  27534. */
  27535. nativeOptions?: any;
  27536. /**
  27537. * Specifies if the parent should be ignored
  27538. */
  27539. ignoreParent?: boolean;
  27540. /**
  27541. * Specifies if bi-directional transformations should be disabled
  27542. */
  27543. disableBidirectionalTransformation?: boolean;
  27544. /**
  27545. * The pressure inside the physics imposter, soft object only
  27546. */
  27547. pressure?: number;
  27548. /**
  27549. * The stiffness the physics imposter, soft object only
  27550. */
  27551. stiffness?: number;
  27552. /**
  27553. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  27554. */
  27555. velocityIterations?: number;
  27556. /**
  27557. * The number of iterations used in maintaining consistent vertex positions, soft object only
  27558. */
  27559. positionIterations?: number;
  27560. /**
  27561. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  27562. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  27563. * Add to fix multiple points
  27564. */
  27565. fixedPoints?: number;
  27566. /**
  27567. * The collision margin around a soft object
  27568. */
  27569. margin?: number;
  27570. /**
  27571. * The collision margin around a soft object
  27572. */
  27573. damping?: number;
  27574. /**
  27575. * The path for a rope based on an extrusion
  27576. */
  27577. path?: any;
  27578. /**
  27579. * The shape of an extrusion used for a rope based on an extrusion
  27580. */
  27581. shape?: any;
  27582. }
  27583. /**
  27584. * Interface for a physics-enabled object
  27585. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27586. */
  27587. export interface IPhysicsEnabledObject {
  27588. /**
  27589. * The position of the physics-enabled object
  27590. */
  27591. position: Vector3;
  27592. /**
  27593. * The rotation of the physics-enabled object
  27594. */
  27595. rotationQuaternion: Nullable<Quaternion>;
  27596. /**
  27597. * The scale of the physics-enabled object
  27598. */
  27599. scaling: Vector3;
  27600. /**
  27601. * The rotation of the physics-enabled object
  27602. */
  27603. rotation?: Vector3;
  27604. /**
  27605. * The parent of the physics-enabled object
  27606. */
  27607. parent?: any;
  27608. /**
  27609. * The bounding info of the physics-enabled object
  27610. * @returns The bounding info of the physics-enabled object
  27611. */
  27612. getBoundingInfo(): BoundingInfo;
  27613. /**
  27614. * Computes the world matrix
  27615. * @param force Specifies if the world matrix should be computed by force
  27616. * @returns A world matrix
  27617. */
  27618. computeWorldMatrix(force: boolean): Matrix;
  27619. /**
  27620. * Gets the world matrix
  27621. * @returns A world matrix
  27622. */
  27623. getWorldMatrix?(): Matrix;
  27624. /**
  27625. * Gets the child meshes
  27626. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  27627. * @returns An array of abstract meshes
  27628. */
  27629. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  27630. /**
  27631. * Gets the vertex data
  27632. * @param kind The type of vertex data
  27633. * @returns A nullable array of numbers, or a float32 array
  27634. */
  27635. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  27636. /**
  27637. * Gets the indices from the mesh
  27638. * @returns A nullable array of index arrays
  27639. */
  27640. getIndices?(): Nullable<IndicesArray>;
  27641. /**
  27642. * Gets the scene from the mesh
  27643. * @returns the indices array or null
  27644. */
  27645. getScene?(): Scene;
  27646. /**
  27647. * Gets the absolute position from the mesh
  27648. * @returns the absolute position
  27649. */
  27650. getAbsolutePosition(): Vector3;
  27651. /**
  27652. * Gets the absolute pivot point from the mesh
  27653. * @returns the absolute pivot point
  27654. */
  27655. getAbsolutePivotPoint(): Vector3;
  27656. /**
  27657. * Rotates the mesh
  27658. * @param axis The axis of rotation
  27659. * @param amount The amount of rotation
  27660. * @param space The space of the rotation
  27661. * @returns The rotation transform node
  27662. */
  27663. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27664. /**
  27665. * Translates the mesh
  27666. * @param axis The axis of translation
  27667. * @param distance The distance of translation
  27668. * @param space The space of the translation
  27669. * @returns The transform node
  27670. */
  27671. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27672. /**
  27673. * Sets the absolute position of the mesh
  27674. * @param absolutePosition The absolute position of the mesh
  27675. * @returns The transform node
  27676. */
  27677. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27678. /**
  27679. * Gets the class name of the mesh
  27680. * @returns The class name
  27681. */
  27682. getClassName(): string;
  27683. }
  27684. /**
  27685. * Represents a physics imposter
  27686. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27687. */
  27688. export class PhysicsImpostor {
  27689. /**
  27690. * The physics-enabled object used as the physics imposter
  27691. */
  27692. object: IPhysicsEnabledObject;
  27693. /**
  27694. * The type of the physics imposter
  27695. */
  27696. type: number;
  27697. private _options;
  27698. private _scene?;
  27699. /**
  27700. * The default object size of the imposter
  27701. */
  27702. static DEFAULT_OBJECT_SIZE: Vector3;
  27703. /**
  27704. * The identity quaternion of the imposter
  27705. */
  27706. static IDENTITY_QUATERNION: Quaternion;
  27707. /** @hidden */
  27708. _pluginData: any;
  27709. private _physicsEngine;
  27710. private _physicsBody;
  27711. private _bodyUpdateRequired;
  27712. private _onBeforePhysicsStepCallbacks;
  27713. private _onAfterPhysicsStepCallbacks;
  27714. /** @hidden */
  27715. _onPhysicsCollideCallbacks: Array<{
  27716. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  27717. otherImpostors: Array<PhysicsImpostor>;
  27718. }>;
  27719. private _deltaPosition;
  27720. private _deltaRotation;
  27721. private _deltaRotationConjugated;
  27722. /** @hidden */
  27723. _isFromLine: boolean;
  27724. private _parent;
  27725. private _isDisposed;
  27726. private static _tmpVecs;
  27727. private static _tmpQuat;
  27728. /**
  27729. * Specifies if the physics imposter is disposed
  27730. */
  27731. get isDisposed(): boolean;
  27732. /**
  27733. * Gets the mass of the physics imposter
  27734. */
  27735. get mass(): number;
  27736. set mass(value: number);
  27737. /**
  27738. * Gets the coefficient of friction
  27739. */
  27740. get friction(): number;
  27741. /**
  27742. * Sets the coefficient of friction
  27743. */
  27744. set friction(value: number);
  27745. /**
  27746. * Gets the coefficient of restitution
  27747. */
  27748. get restitution(): number;
  27749. /**
  27750. * Sets the coefficient of restitution
  27751. */
  27752. set restitution(value: number);
  27753. /**
  27754. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  27755. */
  27756. get pressure(): number;
  27757. /**
  27758. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  27759. */
  27760. set pressure(value: number);
  27761. /**
  27762. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27763. */
  27764. get stiffness(): number;
  27765. /**
  27766. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27767. */
  27768. set stiffness(value: number);
  27769. /**
  27770. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27771. */
  27772. get velocityIterations(): number;
  27773. /**
  27774. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27775. */
  27776. set velocityIterations(value: number);
  27777. /**
  27778. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27779. */
  27780. get positionIterations(): number;
  27781. /**
  27782. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27783. */
  27784. set positionIterations(value: number);
  27785. /**
  27786. * The unique id of the physics imposter
  27787. * set by the physics engine when adding this impostor to the array
  27788. */
  27789. uniqueId: number;
  27790. /**
  27791. * @hidden
  27792. */
  27793. soft: boolean;
  27794. /**
  27795. * @hidden
  27796. */
  27797. segments: number;
  27798. private _joints;
  27799. /**
  27800. * Initializes the physics imposter
  27801. * @param object The physics-enabled object used as the physics imposter
  27802. * @param type The type of the physics imposter
  27803. * @param _options The options for the physics imposter
  27804. * @param _scene The Babylon scene
  27805. */
  27806. constructor(
  27807. /**
  27808. * The physics-enabled object used as the physics imposter
  27809. */
  27810. object: IPhysicsEnabledObject,
  27811. /**
  27812. * The type of the physics imposter
  27813. */
  27814. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  27815. /**
  27816. * This function will completly initialize this impostor.
  27817. * It will create a new body - but only if this mesh has no parent.
  27818. * If it has, this impostor will not be used other than to define the impostor
  27819. * of the child mesh.
  27820. * @hidden
  27821. */
  27822. _init(): void;
  27823. private _getPhysicsParent;
  27824. /**
  27825. * Should a new body be generated.
  27826. * @returns boolean specifying if body initialization is required
  27827. */
  27828. isBodyInitRequired(): boolean;
  27829. /**
  27830. * Sets the updated scaling
  27831. * @param updated Specifies if the scaling is updated
  27832. */
  27833. setScalingUpdated(): void;
  27834. /**
  27835. * Force a regeneration of this or the parent's impostor's body.
  27836. * Use under cautious - This will remove all joints already implemented.
  27837. */
  27838. forceUpdate(): void;
  27839. /**
  27840. * Gets the body that holds this impostor. Either its own, or its parent.
  27841. */
  27842. get physicsBody(): any;
  27843. /**
  27844. * Get the parent of the physics imposter
  27845. * @returns Physics imposter or null
  27846. */
  27847. get parent(): Nullable<PhysicsImpostor>;
  27848. /**
  27849. * Sets the parent of the physics imposter
  27850. */
  27851. set parent(value: Nullable<PhysicsImpostor>);
  27852. /**
  27853. * Set the physics body. Used mainly by the physics engine/plugin
  27854. */
  27855. set physicsBody(physicsBody: any);
  27856. /**
  27857. * Resets the update flags
  27858. */
  27859. resetUpdateFlags(): void;
  27860. /**
  27861. * Gets the object extend size
  27862. * @returns the object extend size
  27863. */
  27864. getObjectExtendSize(): Vector3;
  27865. /**
  27866. * Gets the object center
  27867. * @returns The object center
  27868. */
  27869. getObjectCenter(): Vector3;
  27870. /**
  27871. * Get a specific parameter from the options parameters
  27872. * @param paramName The object parameter name
  27873. * @returns The object parameter
  27874. */
  27875. getParam(paramName: string): any;
  27876. /**
  27877. * Sets a specific parameter in the options given to the physics plugin
  27878. * @param paramName The parameter name
  27879. * @param value The value of the parameter
  27880. */
  27881. setParam(paramName: string, value: number): void;
  27882. /**
  27883. * Specifically change the body's mass option. Won't recreate the physics body object
  27884. * @param mass The mass of the physics imposter
  27885. */
  27886. setMass(mass: number): void;
  27887. /**
  27888. * Gets the linear velocity
  27889. * @returns linear velocity or null
  27890. */
  27891. getLinearVelocity(): Nullable<Vector3>;
  27892. /**
  27893. * Sets the linear velocity
  27894. * @param velocity linear velocity or null
  27895. */
  27896. setLinearVelocity(velocity: Nullable<Vector3>): void;
  27897. /**
  27898. * Gets the angular velocity
  27899. * @returns angular velocity or null
  27900. */
  27901. getAngularVelocity(): Nullable<Vector3>;
  27902. /**
  27903. * Sets the angular velocity
  27904. * @param velocity The velocity or null
  27905. */
  27906. setAngularVelocity(velocity: Nullable<Vector3>): void;
  27907. /**
  27908. * Execute a function with the physics plugin native code
  27909. * Provide a function the will have two variables - the world object and the physics body object
  27910. * @param func The function to execute with the physics plugin native code
  27911. */
  27912. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  27913. /**
  27914. * Register a function that will be executed before the physics world is stepping forward
  27915. * @param func The function to execute before the physics world is stepped forward
  27916. */
  27917. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27918. /**
  27919. * Unregister a function that will be executed before the physics world is stepping forward
  27920. * @param func The function to execute before the physics world is stepped forward
  27921. */
  27922. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27923. /**
  27924. * Register a function that will be executed after the physics step
  27925. * @param func The function to execute after physics step
  27926. */
  27927. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27928. /**
  27929. * Unregisters a function that will be executed after the physics step
  27930. * @param func The function to execute after physics step
  27931. */
  27932. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27933. /**
  27934. * register a function that will be executed when this impostor collides against a different body
  27935. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  27936. * @param func Callback that is executed on collision
  27937. */
  27938. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  27939. /**
  27940. * Unregisters the physics imposter on contact
  27941. * @param collideAgainst The physics object to collide against
  27942. * @param func Callback to execute on collision
  27943. */
  27944. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  27945. private _tmpQuat;
  27946. private _tmpQuat2;
  27947. /**
  27948. * Get the parent rotation
  27949. * @returns The parent rotation
  27950. */
  27951. getParentsRotation(): Quaternion;
  27952. /**
  27953. * this function is executed by the physics engine.
  27954. */
  27955. beforeStep: () => void;
  27956. /**
  27957. * this function is executed by the physics engine
  27958. */
  27959. afterStep: () => void;
  27960. /**
  27961. * Legacy collision detection event support
  27962. */
  27963. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  27964. /**
  27965. * event and body object due to cannon's event-based architecture.
  27966. */
  27967. onCollide: (e: {
  27968. body: any;
  27969. }) => void;
  27970. /**
  27971. * Apply a force
  27972. * @param force The force to apply
  27973. * @param contactPoint The contact point for the force
  27974. * @returns The physics imposter
  27975. */
  27976. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27977. /**
  27978. * Apply an impulse
  27979. * @param force The impulse force
  27980. * @param contactPoint The contact point for the impulse force
  27981. * @returns The physics imposter
  27982. */
  27983. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27984. /**
  27985. * A help function to create a joint
  27986. * @param otherImpostor A physics imposter used to create a joint
  27987. * @param jointType The type of joint
  27988. * @param jointData The data for the joint
  27989. * @returns The physics imposter
  27990. */
  27991. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  27992. /**
  27993. * Add a joint to this impostor with a different impostor
  27994. * @param otherImpostor A physics imposter used to add a joint
  27995. * @param joint The joint to add
  27996. * @returns The physics imposter
  27997. */
  27998. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  27999. /**
  28000. * Add an anchor to a cloth impostor
  28001. * @param otherImpostor rigid impostor to anchor to
  28002. * @param width ratio across width from 0 to 1
  28003. * @param height ratio up height from 0 to 1
  28004. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  28005. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  28006. * @returns impostor the soft imposter
  28007. */
  28008. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28009. /**
  28010. * Add a hook to a rope impostor
  28011. * @param otherImpostor rigid impostor to anchor to
  28012. * @param length ratio across rope from 0 to 1
  28013. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  28014. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  28015. * @returns impostor the rope imposter
  28016. */
  28017. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28018. /**
  28019. * Will keep this body still, in a sleep mode.
  28020. * @returns the physics imposter
  28021. */
  28022. sleep(): PhysicsImpostor;
  28023. /**
  28024. * Wake the body up.
  28025. * @returns The physics imposter
  28026. */
  28027. wakeUp(): PhysicsImpostor;
  28028. /**
  28029. * Clones the physics imposter
  28030. * @param newObject The physics imposter clones to this physics-enabled object
  28031. * @returns A nullable physics imposter
  28032. */
  28033. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28034. /**
  28035. * Disposes the physics imposter
  28036. */
  28037. dispose(): void;
  28038. /**
  28039. * Sets the delta position
  28040. * @param position The delta position amount
  28041. */
  28042. setDeltaPosition(position: Vector3): void;
  28043. /**
  28044. * Sets the delta rotation
  28045. * @param rotation The delta rotation amount
  28046. */
  28047. setDeltaRotation(rotation: Quaternion): void;
  28048. /**
  28049. * Gets the box size of the physics imposter and stores the result in the input parameter
  28050. * @param result Stores the box size
  28051. * @returns The physics imposter
  28052. */
  28053. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  28054. /**
  28055. * Gets the radius of the physics imposter
  28056. * @returns Radius of the physics imposter
  28057. */
  28058. getRadius(): number;
  28059. /**
  28060. * Sync a bone with this impostor
  28061. * @param bone The bone to sync to the impostor.
  28062. * @param boneMesh The mesh that the bone is influencing.
  28063. * @param jointPivot The pivot of the joint / bone in local space.
  28064. * @param distToJoint Optional distance from the impostor to the joint.
  28065. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28066. */
  28067. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  28068. /**
  28069. * Sync impostor to a bone
  28070. * @param bone The bone that the impostor will be synced to.
  28071. * @param boneMesh The mesh that the bone is influencing.
  28072. * @param jointPivot The pivot of the joint / bone in local space.
  28073. * @param distToJoint Optional distance from the impostor to the joint.
  28074. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28075. * @param boneAxis Optional vector3 axis the bone is aligned with
  28076. */
  28077. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  28078. /**
  28079. * No-Imposter type
  28080. */
  28081. static NoImpostor: number;
  28082. /**
  28083. * Sphere-Imposter type
  28084. */
  28085. static SphereImpostor: number;
  28086. /**
  28087. * Box-Imposter type
  28088. */
  28089. static BoxImpostor: number;
  28090. /**
  28091. * Plane-Imposter type
  28092. */
  28093. static PlaneImpostor: number;
  28094. /**
  28095. * Mesh-imposter type
  28096. */
  28097. static MeshImpostor: number;
  28098. /**
  28099. * Capsule-Impostor type (Ammo.js plugin only)
  28100. */
  28101. static CapsuleImpostor: number;
  28102. /**
  28103. * Cylinder-Imposter type
  28104. */
  28105. static CylinderImpostor: number;
  28106. /**
  28107. * Particle-Imposter type
  28108. */
  28109. static ParticleImpostor: number;
  28110. /**
  28111. * Heightmap-Imposter type
  28112. */
  28113. static HeightmapImpostor: number;
  28114. /**
  28115. * ConvexHull-Impostor type (Ammo.js plugin only)
  28116. */
  28117. static ConvexHullImpostor: number;
  28118. /**
  28119. * Custom-Imposter type (Ammo.js plugin only)
  28120. */
  28121. static CustomImpostor: number;
  28122. /**
  28123. * Rope-Imposter type
  28124. */
  28125. static RopeImpostor: number;
  28126. /**
  28127. * Cloth-Imposter type
  28128. */
  28129. static ClothImpostor: number;
  28130. /**
  28131. * Softbody-Imposter type
  28132. */
  28133. static SoftbodyImpostor: number;
  28134. }
  28135. }
  28136. declare module BABYLON {
  28137. /**
  28138. * @hidden
  28139. **/
  28140. export class _CreationDataStorage {
  28141. closePath?: boolean;
  28142. closeArray?: boolean;
  28143. idx: number[];
  28144. dashSize: number;
  28145. gapSize: number;
  28146. path3D: Path3D;
  28147. pathArray: Vector3[][];
  28148. arc: number;
  28149. radius: number;
  28150. cap: number;
  28151. tessellation: number;
  28152. }
  28153. /**
  28154. * @hidden
  28155. **/
  28156. class _InstanceDataStorage {
  28157. visibleInstances: any;
  28158. batchCache: _InstancesBatch;
  28159. instancesBufferSize: number;
  28160. instancesBuffer: Nullable<Buffer>;
  28161. instancesData: Float32Array;
  28162. overridenInstanceCount: number;
  28163. isFrozen: boolean;
  28164. previousBatch: Nullable<_InstancesBatch>;
  28165. hardwareInstancedRendering: boolean;
  28166. sideOrientation: number;
  28167. manualUpdate: boolean;
  28168. previousRenderId: number;
  28169. }
  28170. /**
  28171. * @hidden
  28172. **/
  28173. export class _InstancesBatch {
  28174. mustReturn: boolean;
  28175. visibleInstances: Nullable<InstancedMesh[]>[];
  28176. renderSelf: boolean[];
  28177. hardwareInstancedRendering: boolean[];
  28178. }
  28179. /**
  28180. * @hidden
  28181. **/
  28182. class _ThinInstanceDataStorage {
  28183. instancesCount: number;
  28184. matrixBuffer: Nullable<Buffer>;
  28185. matrixBufferSize: number;
  28186. matrixData: Nullable<Float32Array>;
  28187. boundingVectors: Array<Vector3>;
  28188. worldMatrices: Nullable<Matrix[]>;
  28189. }
  28190. /**
  28191. * Class used to represent renderable models
  28192. */
  28193. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  28194. /**
  28195. * Mesh side orientation : usually the external or front surface
  28196. */
  28197. static readonly FRONTSIDE: number;
  28198. /**
  28199. * Mesh side orientation : usually the internal or back surface
  28200. */
  28201. static readonly BACKSIDE: number;
  28202. /**
  28203. * Mesh side orientation : both internal and external or front and back surfaces
  28204. */
  28205. static readonly DOUBLESIDE: number;
  28206. /**
  28207. * Mesh side orientation : by default, `FRONTSIDE`
  28208. */
  28209. static readonly DEFAULTSIDE: number;
  28210. /**
  28211. * Mesh cap setting : no cap
  28212. */
  28213. static readonly NO_CAP: number;
  28214. /**
  28215. * Mesh cap setting : one cap at the beginning of the mesh
  28216. */
  28217. static readonly CAP_START: number;
  28218. /**
  28219. * Mesh cap setting : one cap at the end of the mesh
  28220. */
  28221. static readonly CAP_END: number;
  28222. /**
  28223. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  28224. */
  28225. static readonly CAP_ALL: number;
  28226. /**
  28227. * Mesh pattern setting : no flip or rotate
  28228. */
  28229. static readonly NO_FLIP: number;
  28230. /**
  28231. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  28232. */
  28233. static readonly FLIP_TILE: number;
  28234. /**
  28235. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  28236. */
  28237. static readonly ROTATE_TILE: number;
  28238. /**
  28239. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  28240. */
  28241. static readonly FLIP_ROW: number;
  28242. /**
  28243. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  28244. */
  28245. static readonly ROTATE_ROW: number;
  28246. /**
  28247. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  28248. */
  28249. static readonly FLIP_N_ROTATE_TILE: number;
  28250. /**
  28251. * Mesh pattern setting : rotate pattern and rotate
  28252. */
  28253. static readonly FLIP_N_ROTATE_ROW: number;
  28254. /**
  28255. * Mesh tile positioning : part tiles same on left/right or top/bottom
  28256. */
  28257. static readonly CENTER: number;
  28258. /**
  28259. * Mesh tile positioning : part tiles on left
  28260. */
  28261. static readonly LEFT: number;
  28262. /**
  28263. * Mesh tile positioning : part tiles on right
  28264. */
  28265. static readonly RIGHT: number;
  28266. /**
  28267. * Mesh tile positioning : part tiles on top
  28268. */
  28269. static readonly TOP: number;
  28270. /**
  28271. * Mesh tile positioning : part tiles on bottom
  28272. */
  28273. static readonly BOTTOM: number;
  28274. /**
  28275. * Gets the default side orientation.
  28276. * @param orientation the orientation to value to attempt to get
  28277. * @returns the default orientation
  28278. * @hidden
  28279. */
  28280. static _GetDefaultSideOrientation(orientation?: number): number;
  28281. private _internalMeshDataInfo;
  28282. get computeBonesUsingShaders(): boolean;
  28283. set computeBonesUsingShaders(value: boolean);
  28284. /**
  28285. * An event triggered before rendering the mesh
  28286. */
  28287. get onBeforeRenderObservable(): Observable<Mesh>;
  28288. /**
  28289. * An event triggered before binding the mesh
  28290. */
  28291. get onBeforeBindObservable(): Observable<Mesh>;
  28292. /**
  28293. * An event triggered after rendering the mesh
  28294. */
  28295. get onAfterRenderObservable(): Observable<Mesh>;
  28296. /**
  28297. * An event triggered before drawing the mesh
  28298. */
  28299. get onBeforeDrawObservable(): Observable<Mesh>;
  28300. private _onBeforeDrawObserver;
  28301. /**
  28302. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  28303. */
  28304. set onBeforeDraw(callback: () => void);
  28305. get hasInstances(): boolean;
  28306. get hasThinInstances(): boolean;
  28307. /**
  28308. * Gets the delay loading state of the mesh (when delay loading is turned on)
  28309. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  28310. */
  28311. delayLoadState: number;
  28312. /**
  28313. * Gets the list of instances created from this mesh
  28314. * it is not supposed to be modified manually.
  28315. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  28316. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28317. */
  28318. instances: InstancedMesh[];
  28319. /**
  28320. * Gets the file containing delay loading data for this mesh
  28321. */
  28322. delayLoadingFile: string;
  28323. /** @hidden */
  28324. _binaryInfo: any;
  28325. /**
  28326. * User defined function used to change how LOD level selection is done
  28327. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28328. */
  28329. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  28330. /**
  28331. * Gets or sets the morph target manager
  28332. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  28333. */
  28334. get morphTargetManager(): Nullable<MorphTargetManager>;
  28335. set morphTargetManager(value: Nullable<MorphTargetManager>);
  28336. /** @hidden */
  28337. _creationDataStorage: Nullable<_CreationDataStorage>;
  28338. /** @hidden */
  28339. _geometry: Nullable<Geometry>;
  28340. /** @hidden */
  28341. _delayInfo: Array<string>;
  28342. /** @hidden */
  28343. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  28344. /** @hidden */
  28345. _instanceDataStorage: _InstanceDataStorage;
  28346. /** @hidden */
  28347. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  28348. private _effectiveMaterial;
  28349. /** @hidden */
  28350. _shouldGenerateFlatShading: boolean;
  28351. /** @hidden */
  28352. _originalBuilderSideOrientation: number;
  28353. /**
  28354. * Use this property to change the original side orientation defined at construction time
  28355. */
  28356. overrideMaterialSideOrientation: Nullable<number>;
  28357. /**
  28358. * Gets the source mesh (the one used to clone this one from)
  28359. */
  28360. get source(): Nullable<Mesh>;
  28361. /**
  28362. * Gets the list of clones of this mesh
  28363. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  28364. * Note that useClonedMeshMap=true is the default setting
  28365. */
  28366. get cloneMeshMap(): Nullable<{
  28367. [id: string]: Mesh | undefined;
  28368. }>;
  28369. /**
  28370. * Gets or sets a boolean indicating that this mesh does not use index buffer
  28371. */
  28372. get isUnIndexed(): boolean;
  28373. set isUnIndexed(value: boolean);
  28374. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  28375. get worldMatrixInstancedBuffer(): Float32Array;
  28376. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  28377. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  28378. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  28379. /**
  28380. * @constructor
  28381. * @param name The value used by scene.getMeshByName() to do a lookup.
  28382. * @param scene The scene to add this mesh to.
  28383. * @param parent The parent of this mesh, if it has one
  28384. * @param source An optional Mesh from which geometry is shared, cloned.
  28385. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28386. * When false, achieved by calling a clone(), also passing False.
  28387. * This will make creation of children, recursive.
  28388. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  28389. */
  28390. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  28391. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  28392. doNotInstantiate: boolean;
  28393. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  28394. /**
  28395. * Gets the class name
  28396. * @returns the string "Mesh".
  28397. */
  28398. getClassName(): string;
  28399. /** @hidden */
  28400. get _isMesh(): boolean;
  28401. /**
  28402. * Returns a description of this mesh
  28403. * @param fullDetails define if full details about this mesh must be used
  28404. * @returns a descriptive string representing this mesh
  28405. */
  28406. toString(fullDetails?: boolean): string;
  28407. /** @hidden */
  28408. _unBindEffect(): void;
  28409. /**
  28410. * Gets a boolean indicating if this mesh has LOD
  28411. */
  28412. get hasLODLevels(): boolean;
  28413. /**
  28414. * Gets the list of MeshLODLevel associated with the current mesh
  28415. * @returns an array of MeshLODLevel
  28416. */
  28417. getLODLevels(): MeshLODLevel[];
  28418. private _sortLODLevels;
  28419. /**
  28420. * Add a mesh as LOD level triggered at the given distance.
  28421. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28422. * @param distance The distance from the center of the object to show this level
  28423. * @param mesh The mesh to be added as LOD level (can be null)
  28424. * @return This mesh (for chaining)
  28425. */
  28426. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  28427. /**
  28428. * Returns the LOD level mesh at the passed distance or null if not found.
  28429. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28430. * @param distance The distance from the center of the object to show this level
  28431. * @returns a Mesh or `null`
  28432. */
  28433. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  28434. /**
  28435. * Remove a mesh from the LOD array
  28436. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28437. * @param mesh defines the mesh to be removed
  28438. * @return This mesh (for chaining)
  28439. */
  28440. removeLODLevel(mesh: Mesh): Mesh;
  28441. /**
  28442. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  28443. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28444. * @param camera defines the camera to use to compute distance
  28445. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  28446. * @return This mesh (for chaining)
  28447. */
  28448. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  28449. /**
  28450. * Gets the mesh internal Geometry object
  28451. */
  28452. get geometry(): Nullable<Geometry>;
  28453. /**
  28454. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  28455. * @returns the total number of vertices
  28456. */
  28457. getTotalVertices(): number;
  28458. /**
  28459. * Returns the content of an associated vertex buffer
  28460. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28461. * - VertexBuffer.PositionKind
  28462. * - VertexBuffer.UVKind
  28463. * - VertexBuffer.UV2Kind
  28464. * - VertexBuffer.UV3Kind
  28465. * - VertexBuffer.UV4Kind
  28466. * - VertexBuffer.UV5Kind
  28467. * - VertexBuffer.UV6Kind
  28468. * - VertexBuffer.ColorKind
  28469. * - VertexBuffer.MatricesIndicesKind
  28470. * - VertexBuffer.MatricesIndicesExtraKind
  28471. * - VertexBuffer.MatricesWeightsKind
  28472. * - VertexBuffer.MatricesWeightsExtraKind
  28473. * @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
  28474. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  28475. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  28476. */
  28477. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  28478. /**
  28479. * Returns the mesh VertexBuffer object from the requested `kind`
  28480. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28481. * - VertexBuffer.PositionKind
  28482. * - VertexBuffer.NormalKind
  28483. * - VertexBuffer.UVKind
  28484. * - VertexBuffer.UV2Kind
  28485. * - VertexBuffer.UV3Kind
  28486. * - VertexBuffer.UV4Kind
  28487. * - VertexBuffer.UV5Kind
  28488. * - VertexBuffer.UV6Kind
  28489. * - VertexBuffer.ColorKind
  28490. * - VertexBuffer.MatricesIndicesKind
  28491. * - VertexBuffer.MatricesIndicesExtraKind
  28492. * - VertexBuffer.MatricesWeightsKind
  28493. * - VertexBuffer.MatricesWeightsExtraKind
  28494. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  28495. */
  28496. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  28497. /**
  28498. * Tests if a specific vertex buffer is associated with this mesh
  28499. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28500. * - VertexBuffer.PositionKind
  28501. * - VertexBuffer.NormalKind
  28502. * - VertexBuffer.UVKind
  28503. * - VertexBuffer.UV2Kind
  28504. * - VertexBuffer.UV3Kind
  28505. * - VertexBuffer.UV4Kind
  28506. * - VertexBuffer.UV5Kind
  28507. * - VertexBuffer.UV6Kind
  28508. * - VertexBuffer.ColorKind
  28509. * - VertexBuffer.MatricesIndicesKind
  28510. * - VertexBuffer.MatricesIndicesExtraKind
  28511. * - VertexBuffer.MatricesWeightsKind
  28512. * - VertexBuffer.MatricesWeightsExtraKind
  28513. * @returns a boolean
  28514. */
  28515. isVerticesDataPresent(kind: string): boolean;
  28516. /**
  28517. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  28518. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28519. * - VertexBuffer.PositionKind
  28520. * - VertexBuffer.UVKind
  28521. * - VertexBuffer.UV2Kind
  28522. * - VertexBuffer.UV3Kind
  28523. * - VertexBuffer.UV4Kind
  28524. * - VertexBuffer.UV5Kind
  28525. * - VertexBuffer.UV6Kind
  28526. * - VertexBuffer.ColorKind
  28527. * - VertexBuffer.MatricesIndicesKind
  28528. * - VertexBuffer.MatricesIndicesExtraKind
  28529. * - VertexBuffer.MatricesWeightsKind
  28530. * - VertexBuffer.MatricesWeightsExtraKind
  28531. * @returns a boolean
  28532. */
  28533. isVertexBufferUpdatable(kind: string): boolean;
  28534. /**
  28535. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  28536. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28537. * - VertexBuffer.PositionKind
  28538. * - VertexBuffer.NormalKind
  28539. * - VertexBuffer.UVKind
  28540. * - VertexBuffer.UV2Kind
  28541. * - VertexBuffer.UV3Kind
  28542. * - VertexBuffer.UV4Kind
  28543. * - VertexBuffer.UV5Kind
  28544. * - VertexBuffer.UV6Kind
  28545. * - VertexBuffer.ColorKind
  28546. * - VertexBuffer.MatricesIndicesKind
  28547. * - VertexBuffer.MatricesIndicesExtraKind
  28548. * - VertexBuffer.MatricesWeightsKind
  28549. * - VertexBuffer.MatricesWeightsExtraKind
  28550. * @returns an array of strings
  28551. */
  28552. getVerticesDataKinds(): string[];
  28553. /**
  28554. * Returns a positive integer : the total number of indices in this mesh geometry.
  28555. * @returns the numner of indices or zero if the mesh has no geometry.
  28556. */
  28557. getTotalIndices(): number;
  28558. /**
  28559. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28560. * @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.
  28561. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  28562. * @returns the indices array or an empty array if the mesh has no geometry
  28563. */
  28564. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  28565. get isBlocked(): boolean;
  28566. /**
  28567. * Determine if the current mesh is ready to be rendered
  28568. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28569. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  28570. * @returns true if all associated assets are ready (material, textures, shaders)
  28571. */
  28572. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  28573. /**
  28574. * 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.
  28575. */
  28576. get areNormalsFrozen(): boolean;
  28577. /**
  28578. * 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.
  28579. * @returns the current mesh
  28580. */
  28581. freezeNormals(): Mesh;
  28582. /**
  28583. * 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
  28584. * @returns the current mesh
  28585. */
  28586. unfreezeNormals(): Mesh;
  28587. /**
  28588. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  28589. */
  28590. set overridenInstanceCount(count: number);
  28591. /** @hidden */
  28592. _preActivate(): Mesh;
  28593. /** @hidden */
  28594. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28595. /** @hidden */
  28596. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  28597. protected _afterComputeWorldMatrix(): void;
  28598. /** @hidden */
  28599. _postActivate(): void;
  28600. /**
  28601. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28602. * This means the mesh underlying bounding box and sphere are recomputed.
  28603. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28604. * @returns the current mesh
  28605. */
  28606. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  28607. /** @hidden */
  28608. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  28609. /**
  28610. * This function will subdivide the mesh into multiple submeshes
  28611. * @param count defines the expected number of submeshes
  28612. */
  28613. subdivide(count: number): void;
  28614. /**
  28615. * Copy a FloatArray into a specific associated vertex buffer
  28616. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28617. * - VertexBuffer.PositionKind
  28618. * - VertexBuffer.UVKind
  28619. * - VertexBuffer.UV2Kind
  28620. * - VertexBuffer.UV3Kind
  28621. * - VertexBuffer.UV4Kind
  28622. * - VertexBuffer.UV5Kind
  28623. * - VertexBuffer.UV6Kind
  28624. * - VertexBuffer.ColorKind
  28625. * - VertexBuffer.MatricesIndicesKind
  28626. * - VertexBuffer.MatricesIndicesExtraKind
  28627. * - VertexBuffer.MatricesWeightsKind
  28628. * - VertexBuffer.MatricesWeightsExtraKind
  28629. * @param data defines the data source
  28630. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28631. * @param stride defines the data stride size (can be null)
  28632. * @returns the current mesh
  28633. */
  28634. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28635. /**
  28636. * Delete a vertex buffer associated with this mesh
  28637. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  28638. * - VertexBuffer.PositionKind
  28639. * - VertexBuffer.UVKind
  28640. * - VertexBuffer.UV2Kind
  28641. * - VertexBuffer.UV3Kind
  28642. * - VertexBuffer.UV4Kind
  28643. * - VertexBuffer.UV5Kind
  28644. * - VertexBuffer.UV6Kind
  28645. * - VertexBuffer.ColorKind
  28646. * - VertexBuffer.MatricesIndicesKind
  28647. * - VertexBuffer.MatricesIndicesExtraKind
  28648. * - VertexBuffer.MatricesWeightsKind
  28649. * - VertexBuffer.MatricesWeightsExtraKind
  28650. */
  28651. removeVerticesData(kind: string): void;
  28652. /**
  28653. * Flags an associated vertex buffer as updatable
  28654. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  28655. * - VertexBuffer.PositionKind
  28656. * - VertexBuffer.UVKind
  28657. * - VertexBuffer.UV2Kind
  28658. * - VertexBuffer.UV3Kind
  28659. * - VertexBuffer.UV4Kind
  28660. * - VertexBuffer.UV5Kind
  28661. * - VertexBuffer.UV6Kind
  28662. * - VertexBuffer.ColorKind
  28663. * - VertexBuffer.MatricesIndicesKind
  28664. * - VertexBuffer.MatricesIndicesExtraKind
  28665. * - VertexBuffer.MatricesWeightsKind
  28666. * - VertexBuffer.MatricesWeightsExtraKind
  28667. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28668. */
  28669. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  28670. /**
  28671. * Sets the mesh global Vertex Buffer
  28672. * @param buffer defines the buffer to use
  28673. * @returns the current mesh
  28674. */
  28675. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  28676. /**
  28677. * Update a specific associated vertex buffer
  28678. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28679. * - VertexBuffer.PositionKind
  28680. * - VertexBuffer.UVKind
  28681. * - VertexBuffer.UV2Kind
  28682. * - VertexBuffer.UV3Kind
  28683. * - VertexBuffer.UV4Kind
  28684. * - VertexBuffer.UV5Kind
  28685. * - VertexBuffer.UV6Kind
  28686. * - VertexBuffer.ColorKind
  28687. * - VertexBuffer.MatricesIndicesKind
  28688. * - VertexBuffer.MatricesIndicesExtraKind
  28689. * - VertexBuffer.MatricesWeightsKind
  28690. * - VertexBuffer.MatricesWeightsExtraKind
  28691. * @param data defines the data source
  28692. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  28693. * @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)
  28694. * @returns the current mesh
  28695. */
  28696. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28697. /**
  28698. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  28699. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  28700. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  28701. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  28702. * @returns the current mesh
  28703. */
  28704. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  28705. /**
  28706. * Creates a un-shared specific occurence of the geometry for the mesh.
  28707. * @returns the current mesh
  28708. */
  28709. makeGeometryUnique(): Mesh;
  28710. /**
  28711. * Set the index buffer of this mesh
  28712. * @param indices defines the source data
  28713. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  28714. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  28715. * @returns the current mesh
  28716. */
  28717. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  28718. /**
  28719. * Update the current index buffer
  28720. * @param indices defines the source data
  28721. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28722. * @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)
  28723. * @returns the current mesh
  28724. */
  28725. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28726. /**
  28727. * Invert the geometry to move from a right handed system to a left handed one.
  28728. * @returns the current mesh
  28729. */
  28730. toLeftHanded(): Mesh;
  28731. /** @hidden */
  28732. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28733. /** @hidden */
  28734. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28735. /**
  28736. * Registers for this mesh a javascript function called just before the rendering process
  28737. * @param func defines the function to call before rendering this mesh
  28738. * @returns the current mesh
  28739. */
  28740. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28741. /**
  28742. * Disposes a previously registered javascript function called before the rendering
  28743. * @param func defines the function to remove
  28744. * @returns the current mesh
  28745. */
  28746. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28747. /**
  28748. * Registers for this mesh a javascript function called just after the rendering is complete
  28749. * @param func defines the function to call after rendering this mesh
  28750. * @returns the current mesh
  28751. */
  28752. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28753. /**
  28754. * Disposes a previously registered javascript function called after the rendering.
  28755. * @param func defines the function to remove
  28756. * @returns the current mesh
  28757. */
  28758. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28759. /** @hidden */
  28760. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  28761. /** @hidden */
  28762. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  28763. /** @hidden */
  28764. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  28765. /** @hidden */
  28766. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  28767. /** @hidden */
  28768. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  28769. /** @hidden */
  28770. _rebuild(): void;
  28771. /** @hidden */
  28772. _freeze(): void;
  28773. /** @hidden */
  28774. _unFreeze(): void;
  28775. /**
  28776. * 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
  28777. * @param subMesh defines the subMesh to render
  28778. * @param enableAlphaMode defines if alpha mode can be changed
  28779. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  28780. * @returns the current mesh
  28781. */
  28782. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  28783. private _onBeforeDraw;
  28784. /**
  28785. * Renormalize the mesh and patch it up if there are no weights
  28786. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  28787. * However in the case of zero weights then we set just a single influence to 1.
  28788. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  28789. */
  28790. cleanMatrixWeights(): void;
  28791. private normalizeSkinFourWeights;
  28792. private normalizeSkinWeightsAndExtra;
  28793. /**
  28794. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  28795. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  28796. * the user know there was an issue with importing the mesh
  28797. * @returns a validation object with skinned, valid and report string
  28798. */
  28799. validateSkinning(): {
  28800. skinned: boolean;
  28801. valid: boolean;
  28802. report: string;
  28803. };
  28804. /** @hidden */
  28805. _checkDelayState(): Mesh;
  28806. private _queueLoad;
  28807. /**
  28808. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28809. * A mesh is in the frustum if its bounding box intersects the frustum
  28810. * @param frustumPlanes defines the frustum to test
  28811. * @returns true if the mesh is in the frustum planes
  28812. */
  28813. isInFrustum(frustumPlanes: Plane[]): boolean;
  28814. /**
  28815. * Sets the mesh material by the material or multiMaterial `id` property
  28816. * @param id is a string identifying the material or the multiMaterial
  28817. * @returns the current mesh
  28818. */
  28819. setMaterialByID(id: string): Mesh;
  28820. /**
  28821. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  28822. * @returns an array of IAnimatable
  28823. */
  28824. getAnimatables(): IAnimatable[];
  28825. /**
  28826. * Modifies the mesh geometry according to the passed transformation matrix.
  28827. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  28828. * The mesh normals are modified using the same transformation.
  28829. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28830. * @param transform defines the transform matrix to use
  28831. * @see https://doc.babylonjs.com/resources/baking_transformations
  28832. * @returns the current mesh
  28833. */
  28834. bakeTransformIntoVertices(transform: Matrix): Mesh;
  28835. /**
  28836. * Modifies the mesh geometry according to its own current World Matrix.
  28837. * The mesh World Matrix is then reset.
  28838. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  28839. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28840. * @see https://doc.babylonjs.com/resources/baking_transformations
  28841. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  28842. * @returns the current mesh
  28843. */
  28844. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  28845. /** @hidden */
  28846. get _positions(): Nullable<Vector3[]>;
  28847. /** @hidden */
  28848. _resetPointsArrayCache(): Mesh;
  28849. /** @hidden */
  28850. _generatePointsArray(): boolean;
  28851. /**
  28852. * Returns a new Mesh object generated from the current mesh properties.
  28853. * This method must not get confused with createInstance()
  28854. * @param name is a string, the name given to the new mesh
  28855. * @param newParent can be any Node object (default `null`)
  28856. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  28857. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  28858. * @returns a new mesh
  28859. */
  28860. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  28861. /**
  28862. * Releases resources associated with this mesh.
  28863. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28864. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28865. */
  28866. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28867. /** @hidden */
  28868. _disposeInstanceSpecificData(): void;
  28869. /** @hidden */
  28870. _disposeThinInstanceSpecificData(): void;
  28871. /**
  28872. * Modifies the mesh geometry according to a displacement map.
  28873. * 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.
  28874. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28875. * @param url is a string, the URL from the image file is to be downloaded.
  28876. * @param minHeight is the lower limit of the displacement.
  28877. * @param maxHeight is the upper limit of the displacement.
  28878. * @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.
  28879. * @param uvOffset is an optional vector2 used to offset UV.
  28880. * @param uvScale is an optional vector2 used to scale UV.
  28881. * @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.
  28882. * @returns the Mesh.
  28883. */
  28884. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28885. /**
  28886. * Modifies the mesh geometry according to a displacementMap buffer.
  28887. * 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.
  28888. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28889. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  28890. * @param heightMapWidth is the width of the buffer image.
  28891. * @param heightMapHeight is the height of the buffer image.
  28892. * @param minHeight is the lower limit of the displacement.
  28893. * @param maxHeight is the upper limit of the displacement.
  28894. * @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.
  28895. * @param uvOffset is an optional vector2 used to offset UV.
  28896. * @param uvScale is an optional vector2 used to scale UV.
  28897. * @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.
  28898. * @returns the Mesh.
  28899. */
  28900. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28901. /**
  28902. * Modify the mesh to get a flat shading rendering.
  28903. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  28904. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  28905. * @returns current mesh
  28906. */
  28907. convertToFlatShadedMesh(): Mesh;
  28908. /**
  28909. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  28910. * In other words, more vertices, no more indices and a single bigger VBO.
  28911. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  28912. * @returns current mesh
  28913. */
  28914. convertToUnIndexedMesh(): Mesh;
  28915. /**
  28916. * Inverses facet orientations.
  28917. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28918. * @param flipNormals will also inverts the normals
  28919. * @returns current mesh
  28920. */
  28921. flipFaces(flipNormals?: boolean): Mesh;
  28922. /**
  28923. * Increase the number of facets and hence vertices in a mesh
  28924. * Vertex normals are interpolated from existing vertex normals
  28925. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28926. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  28927. */
  28928. increaseVertices(numberPerEdge: number): void;
  28929. /**
  28930. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  28931. * This will undo any application of covertToFlatShadedMesh
  28932. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28933. */
  28934. forceSharedVertices(): void;
  28935. /** @hidden */
  28936. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  28937. /** @hidden */
  28938. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  28939. /**
  28940. * Creates a new InstancedMesh object from the mesh model.
  28941. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28942. * @param name defines the name of the new instance
  28943. * @returns a new InstancedMesh
  28944. */
  28945. createInstance(name: string): InstancedMesh;
  28946. /**
  28947. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  28948. * After this call, all the mesh instances have the same submeshes than the current mesh.
  28949. * @returns the current mesh
  28950. */
  28951. synchronizeInstances(): Mesh;
  28952. /**
  28953. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  28954. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  28955. * This should be used together with the simplification to avoid disappearing triangles.
  28956. * @param successCallback an optional success callback to be called after the optimization finished.
  28957. * @returns the current mesh
  28958. */
  28959. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  28960. /**
  28961. * Serialize current mesh
  28962. * @param serializationObject defines the object which will receive the serialization data
  28963. */
  28964. serialize(serializationObject: any): void;
  28965. /** @hidden */
  28966. _syncGeometryWithMorphTargetManager(): void;
  28967. /** @hidden */
  28968. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  28969. /**
  28970. * Returns a new Mesh object parsed from the source provided.
  28971. * @param parsedMesh is the source
  28972. * @param scene defines the hosting scene
  28973. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  28974. * @returns a new Mesh
  28975. */
  28976. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  28977. /**
  28978. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  28979. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28980. * @param name defines the name of the mesh to create
  28981. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  28982. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  28983. * @param closePath creates a seam between the first and the last points of each path of the path array
  28984. * @param offset is taken in account only if the `pathArray` is containing a single path
  28985. * @param scene defines the hosting scene
  28986. * @param updatable defines if the mesh must be flagged as updatable
  28987. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28988. * @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)
  28989. * @returns a new Mesh
  28990. */
  28991. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28992. /**
  28993. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  28994. * @param name defines the name of the mesh to create
  28995. * @param radius sets the radius size (float) of the polygon (default 0.5)
  28996. * @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
  28997. * @param scene defines the hosting scene
  28998. * @param updatable defines if the mesh must be flagged as updatable
  28999. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29000. * @returns a new Mesh
  29001. */
  29002. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  29003. /**
  29004. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  29005. * @param name defines the name of the mesh to create
  29006. * @param size sets the size (float) of each box side (default 1)
  29007. * @param scene defines the hosting scene
  29008. * @param updatable defines if the mesh must be flagged as updatable
  29009. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29010. * @returns a new Mesh
  29011. */
  29012. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  29013. /**
  29014. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  29015. * @param name defines the name of the mesh to create
  29016. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  29017. * @param diameter sets the diameter size (float) of the sphere (default 1)
  29018. * @param scene defines the hosting scene
  29019. * @param updatable defines if the mesh must be flagged as updatable
  29020. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29021. * @returns a new Mesh
  29022. */
  29023. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29024. /**
  29025. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  29026. * @param name defines the name of the mesh to create
  29027. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  29028. * @param diameter sets the diameter size (float) of the sphere (default 1)
  29029. * @param scene defines the hosting scene
  29030. * @returns a new Mesh
  29031. */
  29032. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  29033. /**
  29034. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  29035. * @param name defines the name of the mesh to create
  29036. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  29037. * @param diameterTop set the top cap diameter (floats, default 1)
  29038. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  29039. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  29040. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  29041. * @param scene defines the hosting scene
  29042. * @param updatable defines if the mesh must be flagged as updatable
  29043. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29044. * @returns a new Mesh
  29045. */
  29046. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  29047. /**
  29048. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  29049. * @param name defines the name of the mesh to create
  29050. * @param diameter sets the diameter size (float) of the torus (default 1)
  29051. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  29052. * @param tessellation sets the number of torus sides (postive integer, default 16)
  29053. * @param scene defines the hosting scene
  29054. * @param updatable defines if the mesh must be flagged as updatable
  29055. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29056. * @returns a new Mesh
  29057. */
  29058. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29059. /**
  29060. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  29061. * @param name defines the name of the mesh to create
  29062. * @param radius sets the global radius size (float) of the torus knot (default 2)
  29063. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  29064. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  29065. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  29066. * @param p the number of windings on X axis (positive integers, default 2)
  29067. * @param q the number of windings on Y axis (positive integers, default 3)
  29068. * @param scene defines the hosting scene
  29069. * @param updatable defines if the mesh must be flagged as updatable
  29070. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29071. * @returns a new Mesh
  29072. */
  29073. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29074. /**
  29075. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  29076. * @param name defines the name of the mesh to create
  29077. * @param points is an array successive Vector3
  29078. * @param scene defines the hosting scene
  29079. * @param updatable defines if the mesh must be flagged as updatable
  29080. * @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).
  29081. * @returns a new Mesh
  29082. */
  29083. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  29084. /**
  29085. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  29086. * @param name defines the name of the mesh to create
  29087. * @param points is an array successive Vector3
  29088. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  29089. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  29090. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  29091. * @param scene defines the hosting scene
  29092. * @param updatable defines if the mesh must be flagged as updatable
  29093. * @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)
  29094. * @returns a new Mesh
  29095. */
  29096. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  29097. /**
  29098. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  29099. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  29100. * 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.
  29101. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29102. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  29103. * Remember you can only change the shape positions, not their number when updating a polygon.
  29104. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29105. * @param name defines the name of the mesh to create
  29106. * @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
  29107. * @param scene defines the hosting scene
  29108. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29109. * @param updatable defines if the mesh must be flagged as updatable
  29110. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29111. * @param earcutInjection can be used to inject your own earcut reference
  29112. * @returns a new Mesh
  29113. */
  29114. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29115. /**
  29116. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  29117. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  29118. * @param name defines the name of the mesh to create
  29119. * @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
  29120. * @param depth defines the height of extrusion
  29121. * @param scene defines the hosting scene
  29122. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29123. * @param updatable defines if the mesh must be flagged as updatable
  29124. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29125. * @param earcutInjection can be used to inject your own earcut reference
  29126. * @returns a new Mesh
  29127. */
  29128. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29129. /**
  29130. * Creates an extruded shape mesh.
  29131. * 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
  29132. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29133. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29134. * @param name defines the name of the mesh to create
  29135. * @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
  29136. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29137. * @param scale is the value to scale the shape
  29138. * @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
  29139. * @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
  29140. * @param scene defines the hosting scene
  29141. * @param updatable defines if the mesh must be flagged as updatable
  29142. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29143. * @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)
  29144. * @returns a new Mesh
  29145. */
  29146. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29147. /**
  29148. * Creates an custom extruded shape mesh.
  29149. * The custom extrusion is a parametric shape.
  29150. * It has no predefined shape. Its final shape will depend on the input parameters.
  29151. * Please consider using the same method from the MeshBuilder class instead
  29152. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29153. * @param name defines the name of the mesh to create
  29154. * @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
  29155. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29156. * @param scaleFunction is a custom Javascript function called on each path point
  29157. * @param rotationFunction is a custom Javascript function called on each path point
  29158. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  29159. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  29160. * @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
  29161. * @param scene defines the hosting scene
  29162. * @param updatable defines if the mesh must be flagged as updatable
  29163. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29164. * @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)
  29165. * @returns a new Mesh
  29166. */
  29167. 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;
  29168. /**
  29169. * Creates lathe mesh.
  29170. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  29171. * Please consider using the same method from the MeshBuilder class instead
  29172. * @param name defines the name of the mesh to create
  29173. * @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
  29174. * @param radius is the radius value of the lathe
  29175. * @param tessellation is the side number of the lathe.
  29176. * @param scene defines the hosting scene
  29177. * @param updatable defines if the mesh must be flagged as updatable
  29178. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29179. * @returns a new Mesh
  29180. */
  29181. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29182. /**
  29183. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  29184. * @param name defines the name of the mesh to create
  29185. * @param size sets the size (float) of both sides of the plane at once (default 1)
  29186. * @param scene defines the hosting scene
  29187. * @param updatable defines if the mesh must be flagged as updatable
  29188. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29189. * @returns a new Mesh
  29190. */
  29191. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29192. /**
  29193. * Creates a ground mesh.
  29194. * Please consider using the same method from the MeshBuilder class instead
  29195. * @param name defines the name of the mesh to create
  29196. * @param width set the width of the ground
  29197. * @param height set the height of the ground
  29198. * @param subdivisions sets the number of subdivisions per side
  29199. * @param scene defines the hosting scene
  29200. * @param updatable defines if the mesh must be flagged as updatable
  29201. * @returns a new Mesh
  29202. */
  29203. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  29204. /**
  29205. * Creates a tiled ground mesh.
  29206. * Please consider using the same method from the MeshBuilder class instead
  29207. * @param name defines the name of the mesh to create
  29208. * @param xmin set the ground minimum X coordinate
  29209. * @param zmin set the ground minimum Y coordinate
  29210. * @param xmax set the ground maximum X coordinate
  29211. * @param zmax set the ground maximum Z coordinate
  29212. * @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
  29213. * @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
  29214. * @param scene defines the hosting scene
  29215. * @param updatable defines if the mesh must be flagged as updatable
  29216. * @returns a new Mesh
  29217. */
  29218. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  29219. w: number;
  29220. h: number;
  29221. }, precision: {
  29222. w: number;
  29223. h: number;
  29224. }, scene: Scene, updatable?: boolean): Mesh;
  29225. /**
  29226. * Creates a ground mesh from a height map.
  29227. * Please consider using the same method from the MeshBuilder class instead
  29228. * @see https://doc.babylonjs.com/babylon101/height_map
  29229. * @param name defines the name of the mesh to create
  29230. * @param url sets the URL of the height map image resource
  29231. * @param width set the ground width size
  29232. * @param height set the ground height size
  29233. * @param subdivisions sets the number of subdivision per side
  29234. * @param minHeight is the minimum altitude on the ground
  29235. * @param maxHeight is the maximum altitude on the ground
  29236. * @param scene defines the hosting scene
  29237. * @param updatable defines if the mesh must be flagged as updatable
  29238. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  29239. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  29240. * @returns a new Mesh
  29241. */
  29242. 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;
  29243. /**
  29244. * Creates a tube mesh.
  29245. * The tube is a parametric shape.
  29246. * It has no predefined shape. Its final shape will depend on the input parameters.
  29247. * Please consider using the same method from the MeshBuilder class instead
  29248. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29249. * @param name defines the name of the mesh to create
  29250. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  29251. * @param radius sets the tube radius size
  29252. * @param tessellation is the number of sides on the tubular surface
  29253. * @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
  29254. * @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
  29255. * @param scene defines the hosting scene
  29256. * @param updatable defines if the mesh must be flagged as updatable
  29257. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29258. * @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)
  29259. * @returns a new Mesh
  29260. */
  29261. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  29262. (i: number, distance: number): number;
  29263. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29264. /**
  29265. * Creates a polyhedron mesh.
  29266. * Please consider using the same method from the MeshBuilder class instead.
  29267. * * 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
  29268. * * The parameter `size` (positive float, default 1) sets the polygon size
  29269. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  29270. * * 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`
  29271. * * 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
  29272. * * 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)`)
  29273. * * 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
  29274. * * 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
  29275. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29276. * * 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
  29277. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29278. * @param name defines the name of the mesh to create
  29279. * @param options defines the options used to create the mesh
  29280. * @param scene defines the hosting scene
  29281. * @returns a new Mesh
  29282. */
  29283. static CreatePolyhedron(name: string, options: {
  29284. type?: number;
  29285. size?: number;
  29286. sizeX?: number;
  29287. sizeY?: number;
  29288. sizeZ?: number;
  29289. custom?: any;
  29290. faceUV?: Vector4[];
  29291. faceColors?: Color4[];
  29292. updatable?: boolean;
  29293. sideOrientation?: number;
  29294. }, scene: Scene): Mesh;
  29295. /**
  29296. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  29297. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  29298. * * 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`)
  29299. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  29300. * * 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
  29301. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29302. * * 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
  29303. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29304. * @param name defines the name of the mesh
  29305. * @param options defines the options used to create the mesh
  29306. * @param scene defines the hosting scene
  29307. * @returns a new Mesh
  29308. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  29309. */
  29310. static CreateIcoSphere(name: string, options: {
  29311. radius?: number;
  29312. flat?: boolean;
  29313. subdivisions?: number;
  29314. sideOrientation?: number;
  29315. updatable?: boolean;
  29316. }, scene: Scene): Mesh;
  29317. /**
  29318. * Creates a decal mesh.
  29319. * Please consider using the same method from the MeshBuilder class instead.
  29320. * A decal is a mesh usually applied as a model onto the surface of another mesh
  29321. * @param name defines the name of the mesh
  29322. * @param sourceMesh defines the mesh receiving the decal
  29323. * @param position sets the position of the decal in world coordinates
  29324. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  29325. * @param size sets the decal scaling
  29326. * @param angle sets the angle to rotate the decal
  29327. * @returns a new Mesh
  29328. */
  29329. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  29330. /** Creates a Capsule Mesh
  29331. * @param name defines the name of the mesh.
  29332. * @param options the constructors options used to shape the mesh.
  29333. * @param scene defines the scene the mesh is scoped to.
  29334. * @returns the capsule mesh
  29335. * @see https://doc.babylonjs.com/how_to/capsule_shape
  29336. */
  29337. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  29338. /**
  29339. * Prepare internal position array for software CPU skinning
  29340. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  29341. */
  29342. setPositionsForCPUSkinning(): Float32Array;
  29343. /**
  29344. * Prepare internal normal array for software CPU skinning
  29345. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  29346. */
  29347. setNormalsForCPUSkinning(): Float32Array;
  29348. /**
  29349. * Updates the vertex buffer by applying transformation from the bones
  29350. * @param skeleton defines the skeleton to apply to current mesh
  29351. * @returns the current mesh
  29352. */
  29353. applySkeleton(skeleton: Skeleton): Mesh;
  29354. /**
  29355. * 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
  29356. * @param meshes defines the list of meshes to scan
  29357. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  29358. */
  29359. static MinMax(meshes: AbstractMesh[]): {
  29360. min: Vector3;
  29361. max: Vector3;
  29362. };
  29363. /**
  29364. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  29365. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  29366. * @returns a vector3
  29367. */
  29368. static Center(meshesOrMinMaxVector: {
  29369. min: Vector3;
  29370. max: Vector3;
  29371. } | AbstractMesh[]): Vector3;
  29372. /**
  29373. * Merge the array of meshes into a single mesh for performance reasons.
  29374. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  29375. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  29376. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  29377. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  29378. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  29379. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  29380. * @returns a new mesh
  29381. */
  29382. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  29383. /** @hidden */
  29384. addInstance(instance: InstancedMesh): void;
  29385. /** @hidden */
  29386. removeInstance(instance: InstancedMesh): void;
  29387. }
  29388. }
  29389. declare module BABYLON {
  29390. /**
  29391. * This is the base class of all the camera used in the application.
  29392. * @see https://doc.babylonjs.com/features/cameras
  29393. */
  29394. export class Camera extends Node {
  29395. /** @hidden */
  29396. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29397. /**
  29398. * This is the default projection mode used by the cameras.
  29399. * It helps recreating a feeling of perspective and better appreciate depth.
  29400. * This is the best way to simulate real life cameras.
  29401. */
  29402. static readonly PERSPECTIVE_CAMERA: number;
  29403. /**
  29404. * This helps creating camera with an orthographic mode.
  29405. * 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.
  29406. */
  29407. static readonly ORTHOGRAPHIC_CAMERA: number;
  29408. /**
  29409. * This is the default FOV mode for perspective cameras.
  29410. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29411. */
  29412. static readonly FOVMODE_VERTICAL_FIXED: number;
  29413. /**
  29414. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29415. */
  29416. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29417. /**
  29418. * This specifies ther is no need for a camera rig.
  29419. * Basically only one eye is rendered corresponding to the camera.
  29420. */
  29421. static readonly RIG_MODE_NONE: number;
  29422. /**
  29423. * Simulates a camera Rig with one blue eye and one red eye.
  29424. * This can be use with 3d blue and red glasses.
  29425. */
  29426. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29427. /**
  29428. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29429. */
  29430. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29431. /**
  29432. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29433. */
  29434. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29435. /**
  29436. * Defines that both eyes of the camera will be rendered over under each other.
  29437. */
  29438. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29439. /**
  29440. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  29441. */
  29442. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  29443. /**
  29444. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29445. */
  29446. static readonly RIG_MODE_VR: number;
  29447. /**
  29448. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29449. */
  29450. static readonly RIG_MODE_WEBVR: number;
  29451. /**
  29452. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29453. */
  29454. static readonly RIG_MODE_CUSTOM: number;
  29455. /**
  29456. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29457. */
  29458. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29459. /**
  29460. * Define the input manager associated with the camera.
  29461. */
  29462. inputs: CameraInputsManager<Camera>;
  29463. /** @hidden */
  29464. _position: Vector3;
  29465. /**
  29466. * Define the current local position of the camera in the scene
  29467. */
  29468. get position(): Vector3;
  29469. set position(newPosition: Vector3);
  29470. protected _upVector: Vector3;
  29471. /**
  29472. * The vector the camera should consider as up.
  29473. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29474. */
  29475. set upVector(vec: Vector3);
  29476. get upVector(): Vector3;
  29477. /**
  29478. * Define the current limit on the left side for an orthographic camera
  29479. * In scene unit
  29480. */
  29481. orthoLeft: Nullable<number>;
  29482. /**
  29483. * Define the current limit on the right side for an orthographic camera
  29484. * In scene unit
  29485. */
  29486. orthoRight: Nullable<number>;
  29487. /**
  29488. * Define the current limit on the bottom side for an orthographic camera
  29489. * In scene unit
  29490. */
  29491. orthoBottom: Nullable<number>;
  29492. /**
  29493. * Define the current limit on the top side for an orthographic camera
  29494. * In scene unit
  29495. */
  29496. orthoTop: Nullable<number>;
  29497. /**
  29498. * Field Of View is set in Radians. (default is 0.8)
  29499. */
  29500. fov: number;
  29501. /**
  29502. * Define the minimum distance the camera can see from.
  29503. * This is important to note that the depth buffer are not infinite and the closer it starts
  29504. * the more your scene might encounter depth fighting issue.
  29505. */
  29506. minZ: number;
  29507. /**
  29508. * Define the maximum distance the camera can see to.
  29509. * This is important to note that the depth buffer are not infinite and the further it end
  29510. * the more your scene might encounter depth fighting issue.
  29511. */
  29512. maxZ: number;
  29513. /**
  29514. * Define the default inertia of the camera.
  29515. * This helps giving a smooth feeling to the camera movement.
  29516. */
  29517. inertia: number;
  29518. /**
  29519. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  29520. */
  29521. mode: number;
  29522. /**
  29523. * Define whether the camera is intermediate.
  29524. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29525. */
  29526. isIntermediate: boolean;
  29527. /**
  29528. * Define the viewport of the camera.
  29529. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29530. */
  29531. viewport: Viewport;
  29532. /**
  29533. * Restricts the camera to viewing objects with the same layerMask.
  29534. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29535. */
  29536. layerMask: number;
  29537. /**
  29538. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29539. */
  29540. fovMode: number;
  29541. /**
  29542. * Rig mode of the camera.
  29543. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29544. * This is normally controlled byt the camera themselves as internal use.
  29545. */
  29546. cameraRigMode: number;
  29547. /**
  29548. * Defines the distance between both "eyes" in case of a RIG
  29549. */
  29550. interaxialDistance: number;
  29551. /**
  29552. * Defines if stereoscopic rendering is done side by side or over under.
  29553. */
  29554. isStereoscopicSideBySide: boolean;
  29555. /**
  29556. * 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
  29557. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29558. * else in the scene. (Eg. security camera)
  29559. *
  29560. * 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)
  29561. */
  29562. customRenderTargets: RenderTargetTexture[];
  29563. /**
  29564. * When set, the camera will render to this render target instead of the default canvas
  29565. *
  29566. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  29567. */
  29568. outputRenderTarget: Nullable<RenderTargetTexture>;
  29569. /**
  29570. * Observable triggered when the camera view matrix has changed.
  29571. */
  29572. onViewMatrixChangedObservable: Observable<Camera>;
  29573. /**
  29574. * Observable triggered when the camera Projection matrix has changed.
  29575. */
  29576. onProjectionMatrixChangedObservable: Observable<Camera>;
  29577. /**
  29578. * Observable triggered when the inputs have been processed.
  29579. */
  29580. onAfterCheckInputsObservable: Observable<Camera>;
  29581. /**
  29582. * Observable triggered when reset has been called and applied to the camera.
  29583. */
  29584. onRestoreStateObservable: Observable<Camera>;
  29585. /**
  29586. * Is this camera a part of a rig system?
  29587. */
  29588. isRigCamera: boolean;
  29589. /**
  29590. * If isRigCamera set to true this will be set with the parent camera.
  29591. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  29592. */
  29593. rigParent?: Camera;
  29594. /** @hidden */
  29595. _cameraRigParams: any;
  29596. /** @hidden */
  29597. _rigCameras: Camera[];
  29598. /** @hidden */
  29599. _rigPostProcess: Nullable<PostProcess>;
  29600. protected _webvrViewMatrix: Matrix;
  29601. /** @hidden */
  29602. _skipRendering: boolean;
  29603. /** @hidden */
  29604. _projectionMatrix: Matrix;
  29605. /** @hidden */
  29606. _postProcesses: Nullable<PostProcess>[];
  29607. /** @hidden */
  29608. _activeMeshes: SmartArray<AbstractMesh>;
  29609. protected _globalPosition: Vector3;
  29610. /** @hidden */
  29611. _computedViewMatrix: Matrix;
  29612. private _doNotComputeProjectionMatrix;
  29613. private _transformMatrix;
  29614. private _frustumPlanes;
  29615. private _refreshFrustumPlanes;
  29616. private _storedFov;
  29617. private _stateStored;
  29618. /**
  29619. * Instantiates a new camera object.
  29620. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29621. * @see https://doc.babylonjs.com/features/cameras
  29622. * @param name Defines the name of the camera in the scene
  29623. * @param position Defines the position of the camera
  29624. * @param scene Defines the scene the camera belongs too
  29625. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29626. */
  29627. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29628. /**
  29629. * Store current camera state (fov, position, etc..)
  29630. * @returns the camera
  29631. */
  29632. storeState(): Camera;
  29633. /**
  29634. * Restores the camera state values if it has been stored. You must call storeState() first
  29635. */
  29636. protected _restoreStateValues(): boolean;
  29637. /**
  29638. * Restored camera state. You must call storeState() first.
  29639. * @returns true if restored and false otherwise
  29640. */
  29641. restoreState(): boolean;
  29642. /**
  29643. * Gets the class name of the camera.
  29644. * @returns the class name
  29645. */
  29646. getClassName(): string;
  29647. /** @hidden */
  29648. readonly _isCamera: boolean;
  29649. /**
  29650. * Gets a string representation of the camera useful for debug purpose.
  29651. * @param fullDetails Defines that a more verboe level of logging is required
  29652. * @returns the string representation
  29653. */
  29654. toString(fullDetails?: boolean): string;
  29655. /**
  29656. * Gets the current world space position of the camera.
  29657. */
  29658. get globalPosition(): Vector3;
  29659. /**
  29660. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29661. * @returns the active meshe list
  29662. */
  29663. getActiveMeshes(): SmartArray<AbstractMesh>;
  29664. /**
  29665. * Check whether a mesh is part of the current active mesh list of the camera
  29666. * @param mesh Defines the mesh to check
  29667. * @returns true if active, false otherwise
  29668. */
  29669. isActiveMesh(mesh: Mesh): boolean;
  29670. /**
  29671. * Is this camera ready to be used/rendered
  29672. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29673. * @return true if the camera is ready
  29674. */
  29675. isReady(completeCheck?: boolean): boolean;
  29676. /** @hidden */
  29677. _initCache(): void;
  29678. /** @hidden */
  29679. _updateCache(ignoreParentClass?: boolean): void;
  29680. /** @hidden */
  29681. _isSynchronized(): boolean;
  29682. /** @hidden */
  29683. _isSynchronizedViewMatrix(): boolean;
  29684. /** @hidden */
  29685. _isSynchronizedProjectionMatrix(): boolean;
  29686. /**
  29687. * Attach the input controls to a specific dom element to get the input from.
  29688. * @param element Defines the element the controls should be listened from
  29689. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29690. */
  29691. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29692. /**
  29693. * Detach the current controls from the specified dom element.
  29694. * @param element Defines the element to stop listening the inputs from
  29695. */
  29696. detachControl(element: HTMLElement): void;
  29697. /**
  29698. * Update the camera state according to the different inputs gathered during the frame.
  29699. */
  29700. update(): void;
  29701. /** @hidden */
  29702. _checkInputs(): void;
  29703. /** @hidden */
  29704. get rigCameras(): Camera[];
  29705. /**
  29706. * Gets the post process used by the rig cameras
  29707. */
  29708. get rigPostProcess(): Nullable<PostProcess>;
  29709. /**
  29710. * Internal, gets the first post proces.
  29711. * @returns the first post process to be run on this camera.
  29712. */
  29713. _getFirstPostProcess(): Nullable<PostProcess>;
  29714. private _cascadePostProcessesToRigCams;
  29715. /**
  29716. * Attach a post process to the camera.
  29717. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29718. * @param postProcess The post process to attach to the camera
  29719. * @param insertAt The position of the post process in case several of them are in use in the scene
  29720. * @returns the position the post process has been inserted at
  29721. */
  29722. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29723. /**
  29724. * Detach a post process to the camera.
  29725. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29726. * @param postProcess The post process to detach from the camera
  29727. */
  29728. detachPostProcess(postProcess: PostProcess): void;
  29729. /**
  29730. * Gets the current world matrix of the camera
  29731. */
  29732. getWorldMatrix(): Matrix;
  29733. /** @hidden */
  29734. _getViewMatrix(): Matrix;
  29735. /**
  29736. * Gets the current view matrix of the camera.
  29737. * @param force forces the camera to recompute the matrix without looking at the cached state
  29738. * @returns the view matrix
  29739. */
  29740. getViewMatrix(force?: boolean): Matrix;
  29741. /**
  29742. * Freeze the projection matrix.
  29743. * It will prevent the cache check of the camera projection compute and can speed up perf
  29744. * if no parameter of the camera are meant to change
  29745. * @param projection Defines manually a projection if necessary
  29746. */
  29747. freezeProjectionMatrix(projection?: Matrix): void;
  29748. /**
  29749. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29750. */
  29751. unfreezeProjectionMatrix(): void;
  29752. /**
  29753. * Gets the current projection matrix of the camera.
  29754. * @param force forces the camera to recompute the matrix without looking at the cached state
  29755. * @returns the projection matrix
  29756. */
  29757. getProjectionMatrix(force?: boolean): Matrix;
  29758. /**
  29759. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29760. * @returns a Matrix
  29761. */
  29762. getTransformationMatrix(): Matrix;
  29763. private _updateFrustumPlanes;
  29764. /**
  29765. * Checks if a cullable object (mesh...) is in the camera frustum
  29766. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29767. * @param target The object to check
  29768. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  29769. * @returns true if the object is in frustum otherwise false
  29770. */
  29771. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  29772. /**
  29773. * Checks if a cullable object (mesh...) is in the camera frustum
  29774. * Unlike isInFrustum this cheks the full bounding box
  29775. * @param target The object to check
  29776. * @returns true if the object is in frustum otherwise false
  29777. */
  29778. isCompletelyInFrustum(target: ICullable): boolean;
  29779. /**
  29780. * Gets a ray in the forward direction from the camera.
  29781. * @param length Defines the length of the ray to create
  29782. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29783. * @param origin Defines the start point of the ray which defaults to the camera position
  29784. * @returns the forward ray
  29785. */
  29786. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29787. /**
  29788. * Gets a ray in the forward direction from the camera.
  29789. * @param refRay the ray to (re)use when setting the values
  29790. * @param length Defines the length of the ray to create
  29791. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29792. * @param origin Defines the start point of the ray which defaults to the camera position
  29793. * @returns the forward ray
  29794. */
  29795. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29796. /**
  29797. * Releases resources associated with this node.
  29798. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29799. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29800. */
  29801. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29802. /** @hidden */
  29803. _isLeftCamera: boolean;
  29804. /**
  29805. * Gets the left camera of a rig setup in case of Rigged Camera
  29806. */
  29807. get isLeftCamera(): boolean;
  29808. /** @hidden */
  29809. _isRightCamera: boolean;
  29810. /**
  29811. * Gets the right camera of a rig setup in case of Rigged Camera
  29812. */
  29813. get isRightCamera(): boolean;
  29814. /**
  29815. * Gets the left camera of a rig setup in case of Rigged Camera
  29816. */
  29817. get leftCamera(): Nullable<FreeCamera>;
  29818. /**
  29819. * Gets the right camera of a rig setup in case of Rigged Camera
  29820. */
  29821. get rightCamera(): Nullable<FreeCamera>;
  29822. /**
  29823. * Gets the left camera target of a rig setup in case of Rigged Camera
  29824. * @returns the target position
  29825. */
  29826. getLeftTarget(): Nullable<Vector3>;
  29827. /**
  29828. * Gets the right camera target of a rig setup in case of Rigged Camera
  29829. * @returns the target position
  29830. */
  29831. getRightTarget(): Nullable<Vector3>;
  29832. /**
  29833. * @hidden
  29834. */
  29835. setCameraRigMode(mode: number, rigParams: any): void;
  29836. /** @hidden */
  29837. static _setStereoscopicRigMode(camera: Camera): void;
  29838. /** @hidden */
  29839. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29840. /** @hidden */
  29841. static _setVRRigMode(camera: Camera, rigParams: any): void;
  29842. /** @hidden */
  29843. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29844. /** @hidden */
  29845. _getVRProjectionMatrix(): Matrix;
  29846. protected _updateCameraRotationMatrix(): void;
  29847. protected _updateWebVRCameraRotationMatrix(): void;
  29848. /**
  29849. * This function MUST be overwritten by the different WebVR cameras available.
  29850. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29851. * @hidden
  29852. */
  29853. _getWebVRProjectionMatrix(): Matrix;
  29854. /**
  29855. * This function MUST be overwritten by the different WebVR cameras available.
  29856. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29857. * @hidden
  29858. */
  29859. _getWebVRViewMatrix(): Matrix;
  29860. /** @hidden */
  29861. setCameraRigParameter(name: string, value: any): void;
  29862. /**
  29863. * needs to be overridden by children so sub has required properties to be copied
  29864. * @hidden
  29865. */
  29866. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29867. /**
  29868. * May need to be overridden by children
  29869. * @hidden
  29870. */
  29871. _updateRigCameras(): void;
  29872. /** @hidden */
  29873. _setupInputs(): void;
  29874. /**
  29875. * Serialiaze the camera setup to a json represention
  29876. * @returns the JSON representation
  29877. */
  29878. serialize(): any;
  29879. /**
  29880. * Clones the current camera.
  29881. * @param name The cloned camera name
  29882. * @returns the cloned camera
  29883. */
  29884. clone(name: string): Camera;
  29885. /**
  29886. * Gets the direction of the camera relative to a given local axis.
  29887. * @param localAxis Defines the reference axis to provide a relative direction.
  29888. * @return the direction
  29889. */
  29890. getDirection(localAxis: Vector3): Vector3;
  29891. /**
  29892. * Returns the current camera absolute rotation
  29893. */
  29894. get absoluteRotation(): Quaternion;
  29895. /**
  29896. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29897. * @param localAxis Defines the reference axis to provide a relative direction.
  29898. * @param result Defines the vector to store the result in
  29899. */
  29900. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29901. /**
  29902. * Gets a camera constructor for a given camera type
  29903. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29904. * @param name The name of the camera the result will be able to instantiate
  29905. * @param scene The scene the result will construct the camera in
  29906. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29907. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29908. * @returns a factory method to construc the camera
  29909. */
  29910. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29911. /**
  29912. * Compute the world matrix of the camera.
  29913. * @returns the camera world matrix
  29914. */
  29915. computeWorldMatrix(): Matrix;
  29916. /**
  29917. * Parse a JSON and creates the camera from the parsed information
  29918. * @param parsedCamera The JSON to parse
  29919. * @param scene The scene to instantiate the camera in
  29920. * @returns the newly constructed camera
  29921. */
  29922. static Parse(parsedCamera: any, scene: Scene): Camera;
  29923. }
  29924. }
  29925. declare module BABYLON {
  29926. /**
  29927. * Class containing static functions to help procedurally build meshes
  29928. */
  29929. export class DiscBuilder {
  29930. /**
  29931. * Creates a plane polygonal mesh. By default, this is a disc
  29932. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  29933. * * 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
  29934. * * 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
  29935. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29936. * * 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
  29937. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29938. * @param name defines the name of the mesh
  29939. * @param options defines the options used to create the mesh
  29940. * @param scene defines the hosting scene
  29941. * @returns the plane polygonal mesh
  29942. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  29943. */
  29944. static CreateDisc(name: string, options: {
  29945. radius?: number;
  29946. tessellation?: number;
  29947. arc?: number;
  29948. updatable?: boolean;
  29949. sideOrientation?: number;
  29950. frontUVs?: Vector4;
  29951. backUVs?: Vector4;
  29952. }, scene?: Nullable<Scene>): Mesh;
  29953. }
  29954. }
  29955. declare module BABYLON {
  29956. /**
  29957. * Options to be used when creating a FresnelParameters.
  29958. */
  29959. export type IFresnelParametersCreationOptions = {
  29960. /**
  29961. * Define the color used on edges (grazing angle)
  29962. */
  29963. leftColor?: Color3;
  29964. /**
  29965. * Define the color used on center
  29966. */
  29967. rightColor?: Color3;
  29968. /**
  29969. * Define bias applied to computed fresnel term
  29970. */
  29971. bias?: number;
  29972. /**
  29973. * Defined the power exponent applied to fresnel term
  29974. */
  29975. power?: number;
  29976. /**
  29977. * Define if the fresnel effect is enable or not.
  29978. */
  29979. isEnabled?: boolean;
  29980. };
  29981. /**
  29982. * Serialized format for FresnelParameters.
  29983. */
  29984. export type IFresnelParametersSerialized = {
  29985. /**
  29986. * Define the color used on edges (grazing angle) [as an array]
  29987. */
  29988. leftColor: number[];
  29989. /**
  29990. * Define the color used on center [as an array]
  29991. */
  29992. rightColor: number[];
  29993. /**
  29994. * Define bias applied to computed fresnel term
  29995. */
  29996. bias: number;
  29997. /**
  29998. * Defined the power exponent applied to fresnel term
  29999. */
  30000. power?: number;
  30001. /**
  30002. * Define if the fresnel effect is enable or not.
  30003. */
  30004. isEnabled: boolean;
  30005. };
  30006. /**
  30007. * This represents all the required information to add a fresnel effect on a material:
  30008. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30009. */
  30010. export class FresnelParameters {
  30011. private _isEnabled;
  30012. /**
  30013. * Define if the fresnel effect is enable or not.
  30014. */
  30015. get isEnabled(): boolean;
  30016. set isEnabled(value: boolean);
  30017. /**
  30018. * Define the color used on edges (grazing angle)
  30019. */
  30020. leftColor: Color3;
  30021. /**
  30022. * Define the color used on center
  30023. */
  30024. rightColor: Color3;
  30025. /**
  30026. * Define bias applied to computed fresnel term
  30027. */
  30028. bias: number;
  30029. /**
  30030. * Defined the power exponent applied to fresnel term
  30031. */
  30032. power: number;
  30033. /**
  30034. * Creates a new FresnelParameters object.
  30035. *
  30036. * @param options provide your own settings to optionally to override defaults
  30037. */
  30038. constructor(options?: IFresnelParametersCreationOptions);
  30039. /**
  30040. * Clones the current fresnel and its valuues
  30041. * @returns a clone fresnel configuration
  30042. */
  30043. clone(): FresnelParameters;
  30044. /**
  30045. * Determines equality between FresnelParameters objects
  30046. * @param otherFresnelParameters defines the second operand
  30047. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  30048. */
  30049. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  30050. /**
  30051. * Serializes the current fresnel parameters to a JSON representation.
  30052. * @return the JSON serialization
  30053. */
  30054. serialize(): IFresnelParametersSerialized;
  30055. /**
  30056. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30057. * @param parsedFresnelParameters Define the JSON representation
  30058. * @returns the parsed parameters
  30059. */
  30060. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  30061. }
  30062. }
  30063. declare module BABYLON {
  30064. /**
  30065. * This groups all the flags used to control the materials channel.
  30066. */
  30067. export class MaterialFlags {
  30068. private static _DiffuseTextureEnabled;
  30069. /**
  30070. * Are diffuse textures enabled in the application.
  30071. */
  30072. static get DiffuseTextureEnabled(): boolean;
  30073. static set DiffuseTextureEnabled(value: boolean);
  30074. private static _DetailTextureEnabled;
  30075. /**
  30076. * Are detail textures enabled in the application.
  30077. */
  30078. static get DetailTextureEnabled(): boolean;
  30079. static set DetailTextureEnabled(value: boolean);
  30080. private static _AmbientTextureEnabled;
  30081. /**
  30082. * Are ambient textures enabled in the application.
  30083. */
  30084. static get AmbientTextureEnabled(): boolean;
  30085. static set AmbientTextureEnabled(value: boolean);
  30086. private static _OpacityTextureEnabled;
  30087. /**
  30088. * Are opacity textures enabled in the application.
  30089. */
  30090. static get OpacityTextureEnabled(): boolean;
  30091. static set OpacityTextureEnabled(value: boolean);
  30092. private static _ReflectionTextureEnabled;
  30093. /**
  30094. * Are reflection textures enabled in the application.
  30095. */
  30096. static get ReflectionTextureEnabled(): boolean;
  30097. static set ReflectionTextureEnabled(value: boolean);
  30098. private static _EmissiveTextureEnabled;
  30099. /**
  30100. * Are emissive textures enabled in the application.
  30101. */
  30102. static get EmissiveTextureEnabled(): boolean;
  30103. static set EmissiveTextureEnabled(value: boolean);
  30104. private static _SpecularTextureEnabled;
  30105. /**
  30106. * Are specular textures enabled in the application.
  30107. */
  30108. static get SpecularTextureEnabled(): boolean;
  30109. static set SpecularTextureEnabled(value: boolean);
  30110. private static _BumpTextureEnabled;
  30111. /**
  30112. * Are bump textures enabled in the application.
  30113. */
  30114. static get BumpTextureEnabled(): boolean;
  30115. static set BumpTextureEnabled(value: boolean);
  30116. private static _LightmapTextureEnabled;
  30117. /**
  30118. * Are lightmap textures enabled in the application.
  30119. */
  30120. static get LightmapTextureEnabled(): boolean;
  30121. static set LightmapTextureEnabled(value: boolean);
  30122. private static _RefractionTextureEnabled;
  30123. /**
  30124. * Are refraction textures enabled in the application.
  30125. */
  30126. static get RefractionTextureEnabled(): boolean;
  30127. static set RefractionTextureEnabled(value: boolean);
  30128. private static _ColorGradingTextureEnabled;
  30129. /**
  30130. * Are color grading textures enabled in the application.
  30131. */
  30132. static get ColorGradingTextureEnabled(): boolean;
  30133. static set ColorGradingTextureEnabled(value: boolean);
  30134. private static _FresnelEnabled;
  30135. /**
  30136. * Are fresnels enabled in the application.
  30137. */
  30138. static get FresnelEnabled(): boolean;
  30139. static set FresnelEnabled(value: boolean);
  30140. private static _ClearCoatTextureEnabled;
  30141. /**
  30142. * Are clear coat textures enabled in the application.
  30143. */
  30144. static get ClearCoatTextureEnabled(): boolean;
  30145. static set ClearCoatTextureEnabled(value: boolean);
  30146. private static _ClearCoatBumpTextureEnabled;
  30147. /**
  30148. * Are clear coat bump textures enabled in the application.
  30149. */
  30150. static get ClearCoatBumpTextureEnabled(): boolean;
  30151. static set ClearCoatBumpTextureEnabled(value: boolean);
  30152. private static _ClearCoatTintTextureEnabled;
  30153. /**
  30154. * Are clear coat tint textures enabled in the application.
  30155. */
  30156. static get ClearCoatTintTextureEnabled(): boolean;
  30157. static set ClearCoatTintTextureEnabled(value: boolean);
  30158. private static _SheenTextureEnabled;
  30159. /**
  30160. * Are sheen textures enabled in the application.
  30161. */
  30162. static get SheenTextureEnabled(): boolean;
  30163. static set SheenTextureEnabled(value: boolean);
  30164. private static _AnisotropicTextureEnabled;
  30165. /**
  30166. * Are anisotropic textures enabled in the application.
  30167. */
  30168. static get AnisotropicTextureEnabled(): boolean;
  30169. static set AnisotropicTextureEnabled(value: boolean);
  30170. private static _ThicknessTextureEnabled;
  30171. /**
  30172. * Are thickness textures enabled in the application.
  30173. */
  30174. static get ThicknessTextureEnabled(): boolean;
  30175. static set ThicknessTextureEnabled(value: boolean);
  30176. }
  30177. }
  30178. declare module BABYLON {
  30179. /** @hidden */
  30180. export var defaultFragmentDeclaration: {
  30181. name: string;
  30182. shader: string;
  30183. };
  30184. }
  30185. declare module BABYLON {
  30186. /** @hidden */
  30187. export var defaultUboDeclaration: {
  30188. name: string;
  30189. shader: string;
  30190. };
  30191. }
  30192. declare module BABYLON {
  30193. /** @hidden */
  30194. export var prePassDeclaration: {
  30195. name: string;
  30196. shader: string;
  30197. };
  30198. }
  30199. declare module BABYLON {
  30200. /** @hidden */
  30201. export var lightFragmentDeclaration: {
  30202. name: string;
  30203. shader: string;
  30204. };
  30205. }
  30206. declare module BABYLON {
  30207. /** @hidden */
  30208. export var lightUboDeclaration: {
  30209. name: string;
  30210. shader: string;
  30211. };
  30212. }
  30213. declare module BABYLON {
  30214. /** @hidden */
  30215. export var lightsFragmentFunctions: {
  30216. name: string;
  30217. shader: string;
  30218. };
  30219. }
  30220. declare module BABYLON {
  30221. /** @hidden */
  30222. export var shadowsFragmentFunctions: {
  30223. name: string;
  30224. shader: string;
  30225. };
  30226. }
  30227. declare module BABYLON {
  30228. /** @hidden */
  30229. export var fresnelFunction: {
  30230. name: string;
  30231. shader: string;
  30232. };
  30233. }
  30234. declare module BABYLON {
  30235. /** @hidden */
  30236. export var bumpFragmentMainFunctions: {
  30237. name: string;
  30238. shader: string;
  30239. };
  30240. }
  30241. declare module BABYLON {
  30242. /** @hidden */
  30243. export var bumpFragmentFunctions: {
  30244. name: string;
  30245. shader: string;
  30246. };
  30247. }
  30248. declare module BABYLON {
  30249. /** @hidden */
  30250. export var logDepthDeclaration: {
  30251. name: string;
  30252. shader: string;
  30253. };
  30254. }
  30255. declare module BABYLON {
  30256. /** @hidden */
  30257. export var bumpFragment: {
  30258. name: string;
  30259. shader: string;
  30260. };
  30261. }
  30262. declare module BABYLON {
  30263. /** @hidden */
  30264. export var depthPrePass: {
  30265. name: string;
  30266. shader: string;
  30267. };
  30268. }
  30269. declare module BABYLON {
  30270. /** @hidden */
  30271. export var lightFragment: {
  30272. name: string;
  30273. shader: string;
  30274. };
  30275. }
  30276. declare module BABYLON {
  30277. /** @hidden */
  30278. export var logDepthFragment: {
  30279. name: string;
  30280. shader: string;
  30281. };
  30282. }
  30283. declare module BABYLON {
  30284. /** @hidden */
  30285. export var defaultPixelShader: {
  30286. name: string;
  30287. shader: string;
  30288. };
  30289. }
  30290. declare module BABYLON {
  30291. /** @hidden */
  30292. export var defaultVertexDeclaration: {
  30293. name: string;
  30294. shader: string;
  30295. };
  30296. }
  30297. declare module BABYLON {
  30298. /** @hidden */
  30299. export var bumpVertexDeclaration: {
  30300. name: string;
  30301. shader: string;
  30302. };
  30303. }
  30304. declare module BABYLON {
  30305. /** @hidden */
  30306. export var bumpVertex: {
  30307. name: string;
  30308. shader: string;
  30309. };
  30310. }
  30311. declare module BABYLON {
  30312. /** @hidden */
  30313. export var fogVertex: {
  30314. name: string;
  30315. shader: string;
  30316. };
  30317. }
  30318. declare module BABYLON {
  30319. /** @hidden */
  30320. export var shadowsVertex: {
  30321. name: string;
  30322. shader: string;
  30323. };
  30324. }
  30325. declare module BABYLON {
  30326. /** @hidden */
  30327. export var pointCloudVertex: {
  30328. name: string;
  30329. shader: string;
  30330. };
  30331. }
  30332. declare module BABYLON {
  30333. /** @hidden */
  30334. export var logDepthVertex: {
  30335. name: string;
  30336. shader: string;
  30337. };
  30338. }
  30339. declare module BABYLON {
  30340. /** @hidden */
  30341. export var defaultVertexShader: {
  30342. name: string;
  30343. shader: string;
  30344. };
  30345. }
  30346. declare module BABYLON {
  30347. /**
  30348. * @hidden
  30349. */
  30350. export interface IMaterialDetailMapDefines {
  30351. DETAIL: boolean;
  30352. DETAILDIRECTUV: number;
  30353. DETAIL_NORMALBLENDMETHOD: number;
  30354. /** @hidden */
  30355. _areTexturesDirty: boolean;
  30356. }
  30357. /**
  30358. * Define the code related to the detail map parameters of a material
  30359. *
  30360. * Inspired from:
  30361. * 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
  30362. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  30363. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  30364. */
  30365. export class DetailMapConfiguration {
  30366. private _texture;
  30367. /**
  30368. * The detail texture of the material.
  30369. */
  30370. texture: Nullable<BaseTexture>;
  30371. /**
  30372. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  30373. * Bigger values mean stronger blending
  30374. */
  30375. diffuseBlendLevel: number;
  30376. /**
  30377. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  30378. * Bigger values mean stronger blending. Only used with PBR materials
  30379. */
  30380. roughnessBlendLevel: number;
  30381. /**
  30382. * Defines how strong the bump effect from the detail map is
  30383. * Bigger values mean stronger effect
  30384. */
  30385. bumpLevel: number;
  30386. private _normalBlendMethod;
  30387. /**
  30388. * The method used to blend the bump and detail normals together
  30389. */
  30390. normalBlendMethod: number;
  30391. private _isEnabled;
  30392. /**
  30393. * Enable or disable the detail map on this material
  30394. */
  30395. isEnabled: boolean;
  30396. /** @hidden */
  30397. private _internalMarkAllSubMeshesAsTexturesDirty;
  30398. /** @hidden */
  30399. _markAllSubMeshesAsTexturesDirty(): void;
  30400. /**
  30401. * Instantiate a new detail map
  30402. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  30403. */
  30404. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  30405. /**
  30406. * Gets whether the submesh is ready to be used or not.
  30407. * @param defines the list of "defines" to update.
  30408. * @param scene defines the scene the material belongs to.
  30409. * @returns - boolean indicating that the submesh is ready or not.
  30410. */
  30411. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  30412. /**
  30413. * Update the defines for detail map usage
  30414. * @param defines the list of "defines" to update.
  30415. * @param scene defines the scene the material belongs to.
  30416. */
  30417. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  30418. /**
  30419. * Binds the material data.
  30420. * @param uniformBuffer defines the Uniform buffer to fill in.
  30421. * @param scene defines the scene the material belongs to.
  30422. * @param isFrozen defines whether the material is frozen or not.
  30423. */
  30424. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  30425. /**
  30426. * Checks to see if a texture is used in the material.
  30427. * @param texture - Base texture to use.
  30428. * @returns - Boolean specifying if a texture is used in the material.
  30429. */
  30430. hasTexture(texture: BaseTexture): boolean;
  30431. /**
  30432. * Returns an array of the actively used textures.
  30433. * @param activeTextures Array of BaseTextures
  30434. */
  30435. getActiveTextures(activeTextures: BaseTexture[]): void;
  30436. /**
  30437. * Returns the animatable textures.
  30438. * @param animatables Array of animatable textures.
  30439. */
  30440. getAnimatables(animatables: IAnimatable[]): void;
  30441. /**
  30442. * Disposes the resources of the material.
  30443. * @param forceDisposeTextures - Forces the disposal of all textures.
  30444. */
  30445. dispose(forceDisposeTextures?: boolean): void;
  30446. /**
  30447. * Get the current class name useful for serialization or dynamic coding.
  30448. * @returns "DetailMap"
  30449. */
  30450. getClassName(): string;
  30451. /**
  30452. * Add the required uniforms to the current list.
  30453. * @param uniforms defines the current uniform list.
  30454. */
  30455. static AddUniforms(uniforms: string[]): void;
  30456. /**
  30457. * Add the required samplers to the current list.
  30458. * @param samplers defines the current sampler list.
  30459. */
  30460. static AddSamplers(samplers: string[]): void;
  30461. /**
  30462. * Add the required uniforms to the current buffer.
  30463. * @param uniformBuffer defines the current uniform buffer.
  30464. */
  30465. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  30466. /**
  30467. * Makes a duplicate of the current instance into another one.
  30468. * @param detailMap define the instance where to copy the info
  30469. */
  30470. copyTo(detailMap: DetailMapConfiguration): void;
  30471. /**
  30472. * Serializes this detail map instance
  30473. * @returns - An object with the serialized instance.
  30474. */
  30475. serialize(): any;
  30476. /**
  30477. * Parses a detail map setting from a serialized object.
  30478. * @param source - Serialized object.
  30479. * @param scene Defines the scene we are parsing for
  30480. * @param rootUrl Defines the rootUrl to load from
  30481. */
  30482. parse(source: any, scene: Scene, rootUrl: string): void;
  30483. }
  30484. }
  30485. declare module BABYLON {
  30486. /** @hidden */
  30487. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  30488. MAINUV1: boolean;
  30489. MAINUV2: boolean;
  30490. DIFFUSE: boolean;
  30491. DIFFUSEDIRECTUV: number;
  30492. DETAIL: boolean;
  30493. DETAILDIRECTUV: number;
  30494. DETAIL_NORMALBLENDMETHOD: number;
  30495. AMBIENT: boolean;
  30496. AMBIENTDIRECTUV: number;
  30497. OPACITY: boolean;
  30498. OPACITYDIRECTUV: number;
  30499. OPACITYRGB: boolean;
  30500. REFLECTION: boolean;
  30501. EMISSIVE: boolean;
  30502. EMISSIVEDIRECTUV: number;
  30503. SPECULAR: boolean;
  30504. SPECULARDIRECTUV: number;
  30505. BUMP: boolean;
  30506. BUMPDIRECTUV: number;
  30507. PARALLAX: boolean;
  30508. PARALLAXOCCLUSION: boolean;
  30509. SPECULAROVERALPHA: boolean;
  30510. CLIPPLANE: boolean;
  30511. CLIPPLANE2: boolean;
  30512. CLIPPLANE3: boolean;
  30513. CLIPPLANE4: boolean;
  30514. CLIPPLANE5: boolean;
  30515. CLIPPLANE6: boolean;
  30516. ALPHATEST: boolean;
  30517. DEPTHPREPASS: boolean;
  30518. ALPHAFROMDIFFUSE: boolean;
  30519. POINTSIZE: boolean;
  30520. FOG: boolean;
  30521. SPECULARTERM: boolean;
  30522. DIFFUSEFRESNEL: boolean;
  30523. OPACITYFRESNEL: boolean;
  30524. REFLECTIONFRESNEL: boolean;
  30525. REFRACTIONFRESNEL: boolean;
  30526. EMISSIVEFRESNEL: boolean;
  30527. FRESNEL: boolean;
  30528. NORMAL: boolean;
  30529. UV1: boolean;
  30530. UV2: boolean;
  30531. VERTEXCOLOR: boolean;
  30532. VERTEXALPHA: boolean;
  30533. NUM_BONE_INFLUENCERS: number;
  30534. BonesPerMesh: number;
  30535. BONETEXTURE: boolean;
  30536. INSTANCES: boolean;
  30537. THIN_INSTANCES: boolean;
  30538. GLOSSINESS: boolean;
  30539. ROUGHNESS: boolean;
  30540. EMISSIVEASILLUMINATION: boolean;
  30541. LINKEMISSIVEWITHDIFFUSE: boolean;
  30542. REFLECTIONFRESNELFROMSPECULAR: boolean;
  30543. LIGHTMAP: boolean;
  30544. LIGHTMAPDIRECTUV: number;
  30545. OBJECTSPACE_NORMALMAP: boolean;
  30546. USELIGHTMAPASSHADOWMAP: boolean;
  30547. REFLECTIONMAP_3D: boolean;
  30548. REFLECTIONMAP_SPHERICAL: boolean;
  30549. REFLECTIONMAP_PLANAR: boolean;
  30550. REFLECTIONMAP_CUBIC: boolean;
  30551. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  30552. REFLECTIONMAP_PROJECTION: boolean;
  30553. REFLECTIONMAP_SKYBOX: boolean;
  30554. REFLECTIONMAP_EXPLICIT: boolean;
  30555. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  30556. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  30557. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  30558. INVERTCUBICMAP: boolean;
  30559. LOGARITHMICDEPTH: boolean;
  30560. REFRACTION: boolean;
  30561. REFRACTIONMAP_3D: boolean;
  30562. REFLECTIONOVERALPHA: boolean;
  30563. TWOSIDEDLIGHTING: boolean;
  30564. SHADOWFLOAT: boolean;
  30565. MORPHTARGETS: boolean;
  30566. MORPHTARGETS_NORMAL: boolean;
  30567. MORPHTARGETS_TANGENT: boolean;
  30568. MORPHTARGETS_UV: boolean;
  30569. NUM_MORPH_INFLUENCERS: number;
  30570. NONUNIFORMSCALING: boolean;
  30571. PREMULTIPLYALPHA: boolean;
  30572. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  30573. ALPHABLEND: boolean;
  30574. PREPASS: boolean;
  30575. PREPASS_IRRADIANCE: boolean;
  30576. PREPASS_IRRADIANCE_INDEX: number;
  30577. PREPASS_ALBEDO: boolean;
  30578. PREPASS_ALBEDO_INDEX: number;
  30579. PREPASS_DEPTHNORMAL: boolean;
  30580. PREPASS_DEPTHNORMAL_INDEX: number;
  30581. SCENE_MRT_COUNT: number;
  30582. RGBDLIGHTMAP: boolean;
  30583. RGBDREFLECTION: boolean;
  30584. RGBDREFRACTION: boolean;
  30585. IMAGEPROCESSING: boolean;
  30586. VIGNETTE: boolean;
  30587. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30588. VIGNETTEBLENDMODEOPAQUE: boolean;
  30589. TONEMAPPING: boolean;
  30590. TONEMAPPING_ACES: boolean;
  30591. CONTRAST: boolean;
  30592. COLORCURVES: boolean;
  30593. COLORGRADING: boolean;
  30594. COLORGRADING3D: boolean;
  30595. SAMPLER3DGREENDEPTH: boolean;
  30596. SAMPLER3DBGRMAP: boolean;
  30597. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30598. MULTIVIEW: boolean;
  30599. /**
  30600. * If the reflection texture on this material is in linear color space
  30601. * @hidden
  30602. */
  30603. IS_REFLECTION_LINEAR: boolean;
  30604. /**
  30605. * If the refraction texture on this material is in linear color space
  30606. * @hidden
  30607. */
  30608. IS_REFRACTION_LINEAR: boolean;
  30609. EXPOSURE: boolean;
  30610. constructor();
  30611. setReflectionMode(modeToEnable: string): void;
  30612. }
  30613. /**
  30614. * This is the default material used in Babylon. It is the best trade off between quality
  30615. * and performances.
  30616. * @see https://doc.babylonjs.com/babylon101/materials
  30617. */
  30618. export class StandardMaterial extends PushMaterial {
  30619. private _diffuseTexture;
  30620. /**
  30621. * The basic texture of the material as viewed under a light.
  30622. */
  30623. diffuseTexture: Nullable<BaseTexture>;
  30624. private _ambientTexture;
  30625. /**
  30626. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  30627. */
  30628. ambientTexture: Nullable<BaseTexture>;
  30629. private _opacityTexture;
  30630. /**
  30631. * Define the transparency of the material from a texture.
  30632. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  30633. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  30634. */
  30635. opacityTexture: Nullable<BaseTexture>;
  30636. private _reflectionTexture;
  30637. /**
  30638. * Define the texture used to display the reflection.
  30639. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30640. */
  30641. reflectionTexture: Nullable<BaseTexture>;
  30642. private _emissiveTexture;
  30643. /**
  30644. * Define texture of the material as if self lit.
  30645. * This will be mixed in the final result even in the absence of light.
  30646. */
  30647. emissiveTexture: Nullable<BaseTexture>;
  30648. private _specularTexture;
  30649. /**
  30650. * Define how the color and intensity of the highlight given by the light in the material.
  30651. */
  30652. specularTexture: Nullable<BaseTexture>;
  30653. private _bumpTexture;
  30654. /**
  30655. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  30656. * 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.
  30657. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  30658. */
  30659. bumpTexture: Nullable<BaseTexture>;
  30660. private _lightmapTexture;
  30661. /**
  30662. * Complex lighting can be computationally expensive to compute at runtime.
  30663. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  30664. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  30665. */
  30666. lightmapTexture: Nullable<BaseTexture>;
  30667. private _refractionTexture;
  30668. /**
  30669. * Define the texture used to display the refraction.
  30670. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30671. */
  30672. refractionTexture: Nullable<BaseTexture>;
  30673. /**
  30674. * The color of the material lit by the environmental background lighting.
  30675. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  30676. */
  30677. ambientColor: Color3;
  30678. /**
  30679. * The basic color of the material as viewed under a light.
  30680. */
  30681. diffuseColor: Color3;
  30682. /**
  30683. * Define how the color and intensity of the highlight given by the light in the material.
  30684. */
  30685. specularColor: Color3;
  30686. /**
  30687. * Define the color of the material as if self lit.
  30688. * This will be mixed in the final result even in the absence of light.
  30689. */
  30690. emissiveColor: Color3;
  30691. /**
  30692. * Defines how sharp are the highlights in the material.
  30693. * The bigger the value the sharper giving a more glossy feeling to the result.
  30694. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  30695. */
  30696. specularPower: number;
  30697. private _useAlphaFromDiffuseTexture;
  30698. /**
  30699. * Does the transparency come from the diffuse texture alpha channel.
  30700. */
  30701. useAlphaFromDiffuseTexture: boolean;
  30702. private _useEmissiveAsIllumination;
  30703. /**
  30704. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  30705. */
  30706. useEmissiveAsIllumination: boolean;
  30707. private _linkEmissiveWithDiffuse;
  30708. /**
  30709. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  30710. * the emissive level when the final color is close to one.
  30711. */
  30712. linkEmissiveWithDiffuse: boolean;
  30713. private _useSpecularOverAlpha;
  30714. /**
  30715. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  30716. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  30717. */
  30718. useSpecularOverAlpha: boolean;
  30719. private _useReflectionOverAlpha;
  30720. /**
  30721. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  30722. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  30723. */
  30724. useReflectionOverAlpha: boolean;
  30725. private _disableLighting;
  30726. /**
  30727. * Does lights from the scene impacts this material.
  30728. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  30729. */
  30730. disableLighting: boolean;
  30731. private _useObjectSpaceNormalMap;
  30732. /**
  30733. * Allows using an object space normal map (instead of tangent space).
  30734. */
  30735. useObjectSpaceNormalMap: boolean;
  30736. private _useParallax;
  30737. /**
  30738. * Is parallax enabled or not.
  30739. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30740. */
  30741. useParallax: boolean;
  30742. private _useParallaxOcclusion;
  30743. /**
  30744. * Is parallax occlusion enabled or not.
  30745. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  30746. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30747. */
  30748. useParallaxOcclusion: boolean;
  30749. /**
  30750. * 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.
  30751. */
  30752. parallaxScaleBias: number;
  30753. private _roughness;
  30754. /**
  30755. * Helps to define how blurry the reflections should appears in the material.
  30756. */
  30757. roughness: number;
  30758. /**
  30759. * In case of refraction, define the value of the index of refraction.
  30760. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30761. */
  30762. indexOfRefraction: number;
  30763. /**
  30764. * Invert the refraction texture alongside the y axis.
  30765. * It can be useful with procedural textures or probe for instance.
  30766. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30767. */
  30768. invertRefractionY: boolean;
  30769. /**
  30770. * Defines the alpha limits in alpha test mode.
  30771. */
  30772. alphaCutOff: number;
  30773. private _useLightmapAsShadowmap;
  30774. /**
  30775. * In case of light mapping, define whether the map contains light or shadow informations.
  30776. */
  30777. useLightmapAsShadowmap: boolean;
  30778. private _diffuseFresnelParameters;
  30779. /**
  30780. * Define the diffuse fresnel parameters of the material.
  30781. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30782. */
  30783. diffuseFresnelParameters: FresnelParameters;
  30784. private _opacityFresnelParameters;
  30785. /**
  30786. * Define the opacity fresnel parameters of the material.
  30787. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30788. */
  30789. opacityFresnelParameters: FresnelParameters;
  30790. private _reflectionFresnelParameters;
  30791. /**
  30792. * Define the reflection fresnel parameters of the material.
  30793. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30794. */
  30795. reflectionFresnelParameters: FresnelParameters;
  30796. private _refractionFresnelParameters;
  30797. /**
  30798. * Define the refraction fresnel parameters of the material.
  30799. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30800. */
  30801. refractionFresnelParameters: FresnelParameters;
  30802. private _emissiveFresnelParameters;
  30803. /**
  30804. * Define the emissive fresnel parameters of the material.
  30805. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30806. */
  30807. emissiveFresnelParameters: FresnelParameters;
  30808. private _useReflectionFresnelFromSpecular;
  30809. /**
  30810. * If true automatically deducts the fresnels values from the material specularity.
  30811. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30812. */
  30813. useReflectionFresnelFromSpecular: boolean;
  30814. private _useGlossinessFromSpecularMapAlpha;
  30815. /**
  30816. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  30817. */
  30818. useGlossinessFromSpecularMapAlpha: boolean;
  30819. private _maxSimultaneousLights;
  30820. /**
  30821. * Defines the maximum number of lights that can be used in the material
  30822. */
  30823. maxSimultaneousLights: number;
  30824. private _invertNormalMapX;
  30825. /**
  30826. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  30827. */
  30828. invertNormalMapX: boolean;
  30829. private _invertNormalMapY;
  30830. /**
  30831. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  30832. */
  30833. invertNormalMapY: boolean;
  30834. private _twoSidedLighting;
  30835. /**
  30836. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  30837. */
  30838. twoSidedLighting: boolean;
  30839. /**
  30840. * Default configuration related to image processing available in the standard Material.
  30841. */
  30842. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30843. /**
  30844. * Gets the image processing configuration used either in this material.
  30845. */
  30846. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  30847. /**
  30848. * Sets the Default image processing configuration used either in the this material.
  30849. *
  30850. * If sets to null, the scene one is in use.
  30851. */
  30852. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  30853. /**
  30854. * Keep track of the image processing observer to allow dispose and replace.
  30855. */
  30856. private _imageProcessingObserver;
  30857. /**
  30858. * Attaches a new image processing configuration to the Standard Material.
  30859. * @param configuration
  30860. */
  30861. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30862. /**
  30863. * Gets wether the color curves effect is enabled.
  30864. */
  30865. get cameraColorCurvesEnabled(): boolean;
  30866. /**
  30867. * Sets wether the color curves effect is enabled.
  30868. */
  30869. set cameraColorCurvesEnabled(value: boolean);
  30870. /**
  30871. * Gets wether the color grading effect is enabled.
  30872. */
  30873. get cameraColorGradingEnabled(): boolean;
  30874. /**
  30875. * Gets wether the color grading effect is enabled.
  30876. */
  30877. set cameraColorGradingEnabled(value: boolean);
  30878. /**
  30879. * Gets wether tonemapping is enabled or not.
  30880. */
  30881. get cameraToneMappingEnabled(): boolean;
  30882. /**
  30883. * Sets wether tonemapping is enabled or not
  30884. */
  30885. set cameraToneMappingEnabled(value: boolean);
  30886. /**
  30887. * The camera exposure used on this material.
  30888. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30889. * This corresponds to a photographic exposure.
  30890. */
  30891. get cameraExposure(): number;
  30892. /**
  30893. * The camera exposure used on this material.
  30894. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30895. * This corresponds to a photographic exposure.
  30896. */
  30897. set cameraExposure(value: number);
  30898. /**
  30899. * Gets The camera contrast used on this material.
  30900. */
  30901. get cameraContrast(): number;
  30902. /**
  30903. * Sets The camera contrast used on this material.
  30904. */
  30905. set cameraContrast(value: number);
  30906. /**
  30907. * Gets the Color Grading 2D Lookup Texture.
  30908. */
  30909. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  30910. /**
  30911. * Sets the Color Grading 2D Lookup Texture.
  30912. */
  30913. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  30914. /**
  30915. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30916. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30917. * 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;
  30918. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30919. */
  30920. get cameraColorCurves(): Nullable<ColorCurves>;
  30921. /**
  30922. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30923. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30924. * 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;
  30925. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30926. */
  30927. set cameraColorCurves(value: Nullable<ColorCurves>);
  30928. /**
  30929. * Can this material render to several textures at once
  30930. */
  30931. get canRenderToMRT(): boolean;
  30932. /**
  30933. * Defines the detail map parameters for the material.
  30934. */
  30935. readonly detailMap: DetailMapConfiguration;
  30936. protected _renderTargets: SmartArray<RenderTargetTexture>;
  30937. protected _worldViewProjectionMatrix: Matrix;
  30938. protected _globalAmbientColor: Color3;
  30939. protected _useLogarithmicDepth: boolean;
  30940. protected _rebuildInParallel: boolean;
  30941. /**
  30942. * Instantiates a new standard material.
  30943. * This is the default material used in Babylon. It is the best trade off between quality
  30944. * and performances.
  30945. * @see https://doc.babylonjs.com/babylon101/materials
  30946. * @param name Define the name of the material in the scene
  30947. * @param scene Define the scene the material belong to
  30948. */
  30949. constructor(name: string, scene: Scene);
  30950. /**
  30951. * Gets a boolean indicating that current material needs to register RTT
  30952. */
  30953. get hasRenderTargetTextures(): boolean;
  30954. /**
  30955. * Gets the current class name of the material e.g. "StandardMaterial"
  30956. * Mainly use in serialization.
  30957. * @returns the class name
  30958. */
  30959. getClassName(): string;
  30960. /**
  30961. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  30962. * You can try switching to logarithmic depth.
  30963. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  30964. */
  30965. get useLogarithmicDepth(): boolean;
  30966. set useLogarithmicDepth(value: boolean);
  30967. /**
  30968. * Specifies if the material will require alpha blending
  30969. * @returns a boolean specifying if alpha blending is needed
  30970. */
  30971. needAlphaBlending(): boolean;
  30972. /**
  30973. * Specifies if this material should be rendered in alpha test mode
  30974. * @returns a boolean specifying if an alpha test is needed.
  30975. */
  30976. needAlphaTesting(): boolean;
  30977. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  30978. /**
  30979. * Get the texture used for alpha test purpose.
  30980. * @returns the diffuse texture in case of the standard material.
  30981. */
  30982. getAlphaTestTexture(): Nullable<BaseTexture>;
  30983. /**
  30984. * Get if the submesh is ready to be used and all its information available.
  30985. * Child classes can use it to update shaders
  30986. * @param mesh defines the mesh to check
  30987. * @param subMesh defines which submesh to check
  30988. * @param useInstances specifies that instances should be used
  30989. * @returns a boolean indicating that the submesh is ready or not
  30990. */
  30991. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30992. /**
  30993. * Builds the material UBO layouts.
  30994. * Used internally during the effect preparation.
  30995. */
  30996. buildUniformLayout(): void;
  30997. /**
  30998. * Unbinds the material from the mesh
  30999. */
  31000. unbind(): void;
  31001. /**
  31002. * Binds the submesh to this material by preparing the effect and shader to draw
  31003. * @param world defines the world transformation matrix
  31004. * @param mesh defines the mesh containing the submesh
  31005. * @param subMesh defines the submesh to bind the material to
  31006. */
  31007. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  31008. /**
  31009. * Get the list of animatables in the material.
  31010. * @returns the list of animatables object used in the material
  31011. */
  31012. getAnimatables(): IAnimatable[];
  31013. /**
  31014. * Gets the active textures from the material
  31015. * @returns an array of textures
  31016. */
  31017. getActiveTextures(): BaseTexture[];
  31018. /**
  31019. * Specifies if the material uses a texture
  31020. * @param texture defines the texture to check against the material
  31021. * @returns a boolean specifying if the material uses the texture
  31022. */
  31023. hasTexture(texture: BaseTexture): boolean;
  31024. /**
  31025. * Disposes the material
  31026. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  31027. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  31028. */
  31029. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  31030. /**
  31031. * Makes a duplicate of the material, and gives it a new name
  31032. * @param name defines the new name for the duplicated material
  31033. * @returns the cloned material
  31034. */
  31035. clone(name: string): StandardMaterial;
  31036. /**
  31037. * Serializes this material in a JSON representation
  31038. * @returns the serialized material object
  31039. */
  31040. serialize(): any;
  31041. /**
  31042. * Creates a standard material from parsed material data
  31043. * @param source defines the JSON representation of the material
  31044. * @param scene defines the hosting scene
  31045. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  31046. * @returns a new standard material
  31047. */
  31048. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  31049. /**
  31050. * Are diffuse textures enabled in the application.
  31051. */
  31052. static get DiffuseTextureEnabled(): boolean;
  31053. static set DiffuseTextureEnabled(value: boolean);
  31054. /**
  31055. * Are detail textures enabled in the application.
  31056. */
  31057. static get DetailTextureEnabled(): boolean;
  31058. static set DetailTextureEnabled(value: boolean);
  31059. /**
  31060. * Are ambient textures enabled in the application.
  31061. */
  31062. static get AmbientTextureEnabled(): boolean;
  31063. static set AmbientTextureEnabled(value: boolean);
  31064. /**
  31065. * Are opacity textures enabled in the application.
  31066. */
  31067. static get OpacityTextureEnabled(): boolean;
  31068. static set OpacityTextureEnabled(value: boolean);
  31069. /**
  31070. * Are reflection textures enabled in the application.
  31071. */
  31072. static get ReflectionTextureEnabled(): boolean;
  31073. static set ReflectionTextureEnabled(value: boolean);
  31074. /**
  31075. * Are emissive textures enabled in the application.
  31076. */
  31077. static get EmissiveTextureEnabled(): boolean;
  31078. static set EmissiveTextureEnabled(value: boolean);
  31079. /**
  31080. * Are specular textures enabled in the application.
  31081. */
  31082. static get SpecularTextureEnabled(): boolean;
  31083. static set SpecularTextureEnabled(value: boolean);
  31084. /**
  31085. * Are bump textures enabled in the application.
  31086. */
  31087. static get BumpTextureEnabled(): boolean;
  31088. static set BumpTextureEnabled(value: boolean);
  31089. /**
  31090. * Are lightmap textures enabled in the application.
  31091. */
  31092. static get LightmapTextureEnabled(): boolean;
  31093. static set LightmapTextureEnabled(value: boolean);
  31094. /**
  31095. * Are refraction textures enabled in the application.
  31096. */
  31097. static get RefractionTextureEnabled(): boolean;
  31098. static set RefractionTextureEnabled(value: boolean);
  31099. /**
  31100. * Are color grading textures enabled in the application.
  31101. */
  31102. static get ColorGradingTextureEnabled(): boolean;
  31103. static set ColorGradingTextureEnabled(value: boolean);
  31104. /**
  31105. * Are fresnels enabled in the application.
  31106. */
  31107. static get FresnelEnabled(): boolean;
  31108. static set FresnelEnabled(value: boolean);
  31109. }
  31110. }
  31111. declare module BABYLON {
  31112. /**
  31113. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  31114. *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.
  31115. * The SPS is also a particle system. It provides some methods to manage the particles.
  31116. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  31117. *
  31118. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  31119. */
  31120. export class SolidParticleSystem implements IDisposable {
  31121. /**
  31122. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  31123. * Example : var p = SPS.particles[i];
  31124. */
  31125. particles: SolidParticle[];
  31126. /**
  31127. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  31128. */
  31129. nbParticles: number;
  31130. /**
  31131. * If the particles must ever face the camera (default false). Useful for planar particles.
  31132. */
  31133. billboard: boolean;
  31134. /**
  31135. * Recompute normals when adding a shape
  31136. */
  31137. recomputeNormals: boolean;
  31138. /**
  31139. * This a counter ofr your own usage. It's not set by any SPS functions.
  31140. */
  31141. counter: number;
  31142. /**
  31143. * The SPS name. This name is also given to the underlying mesh.
  31144. */
  31145. name: string;
  31146. /**
  31147. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  31148. */
  31149. mesh: Mesh;
  31150. /**
  31151. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  31152. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  31153. */
  31154. vars: any;
  31155. /**
  31156. * This array is populated when the SPS is set as 'pickable'.
  31157. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  31158. * Each element of this array is an object `{idx: int, faceId: int}`.
  31159. * `idx` is the picked particle index in the `SPS.particles` array
  31160. * `faceId` is the picked face index counted within this particle.
  31161. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  31162. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  31163. * Use the method SPS.pickedParticle(pickingInfo) instead.
  31164. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31165. */
  31166. pickedParticles: {
  31167. idx: number;
  31168. faceId: number;
  31169. }[];
  31170. /**
  31171. * This array is populated when the SPS is set as 'pickable'
  31172. * Each key of this array is a submesh index.
  31173. * Each element of this array is a second array defined like this :
  31174. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  31175. * Each element of this second array is an object `{idx: int, faceId: int}`.
  31176. * `idx` is the picked particle index in the `SPS.particles` array
  31177. * `faceId` is the picked face index counted within this particle.
  31178. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  31179. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31180. */
  31181. pickedBySubMesh: {
  31182. idx: number;
  31183. faceId: number;
  31184. }[][];
  31185. /**
  31186. * This array is populated when `enableDepthSort` is set to true.
  31187. * Each element of this array is an instance of the class DepthSortedParticle.
  31188. */
  31189. depthSortedParticles: DepthSortedParticle[];
  31190. /**
  31191. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  31192. * @hidden
  31193. */
  31194. _bSphereOnly: boolean;
  31195. /**
  31196. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  31197. * @hidden
  31198. */
  31199. _bSphereRadiusFactor: number;
  31200. private _scene;
  31201. private _positions;
  31202. private _indices;
  31203. private _normals;
  31204. private _colors;
  31205. private _uvs;
  31206. private _indices32;
  31207. private _positions32;
  31208. private _normals32;
  31209. private _fixedNormal32;
  31210. private _colors32;
  31211. private _uvs32;
  31212. private _index;
  31213. private _updatable;
  31214. private _pickable;
  31215. private _isVisibilityBoxLocked;
  31216. private _alwaysVisible;
  31217. private _depthSort;
  31218. private _expandable;
  31219. private _shapeCounter;
  31220. private _copy;
  31221. private _color;
  31222. private _computeParticleColor;
  31223. private _computeParticleTexture;
  31224. private _computeParticleRotation;
  31225. private _computeParticleVertex;
  31226. private _computeBoundingBox;
  31227. private _depthSortParticles;
  31228. private _camera;
  31229. private _mustUnrotateFixedNormals;
  31230. private _particlesIntersect;
  31231. private _needs32Bits;
  31232. private _isNotBuilt;
  31233. private _lastParticleId;
  31234. private _idxOfId;
  31235. private _multimaterialEnabled;
  31236. private _useModelMaterial;
  31237. private _indicesByMaterial;
  31238. private _materialIndexes;
  31239. private _depthSortFunction;
  31240. private _materialSortFunction;
  31241. private _materials;
  31242. private _multimaterial;
  31243. private _materialIndexesById;
  31244. private _defaultMaterial;
  31245. private _autoUpdateSubMeshes;
  31246. private _tmpVertex;
  31247. /**
  31248. * Creates a SPS (Solid Particle System) object.
  31249. * @param name (String) is the SPS name, this will be the underlying mesh name.
  31250. * @param scene (Scene) is the scene in which the SPS is added.
  31251. * @param options defines the options of the sps e.g.
  31252. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  31253. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  31254. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  31255. * * 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.
  31256. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  31257. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  31258. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  31259. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  31260. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  31261. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  31262. */
  31263. constructor(name: string, scene: Scene, options?: {
  31264. updatable?: boolean;
  31265. isPickable?: boolean;
  31266. enableDepthSort?: boolean;
  31267. particleIntersection?: boolean;
  31268. boundingSphereOnly?: boolean;
  31269. bSphereRadiusFactor?: number;
  31270. expandable?: boolean;
  31271. useModelMaterial?: boolean;
  31272. enableMultiMaterial?: boolean;
  31273. });
  31274. /**
  31275. * Builds the SPS underlying mesh. Returns a standard Mesh.
  31276. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  31277. * @returns the created mesh
  31278. */
  31279. buildMesh(): Mesh;
  31280. /**
  31281. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  31282. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  31283. * Thus the particles generated from `digest()` have their property `position` set yet.
  31284. * @param mesh ( Mesh ) is the mesh to be digested
  31285. * @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
  31286. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  31287. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  31288. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31289. * @returns the current SPS
  31290. */
  31291. digest(mesh: Mesh, options?: {
  31292. facetNb?: number;
  31293. number?: number;
  31294. delta?: number;
  31295. storage?: [];
  31296. }): SolidParticleSystem;
  31297. /**
  31298. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  31299. * @hidden
  31300. */
  31301. private _unrotateFixedNormals;
  31302. /**
  31303. * Resets the temporary working copy particle
  31304. * @hidden
  31305. */
  31306. private _resetCopy;
  31307. /**
  31308. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  31309. * @param p the current index in the positions array to be updated
  31310. * @param ind the current index in the indices array
  31311. * @param shape a Vector3 array, the shape geometry
  31312. * @param positions the positions array to be updated
  31313. * @param meshInd the shape indices array
  31314. * @param indices the indices array to be updated
  31315. * @param meshUV the shape uv array
  31316. * @param uvs the uv array to be updated
  31317. * @param meshCol the shape color array
  31318. * @param colors the color array to be updated
  31319. * @param meshNor the shape normals array
  31320. * @param normals the normals array to be updated
  31321. * @param idx the particle index
  31322. * @param idxInShape the particle index in its shape
  31323. * @param options the addShape() method passed options
  31324. * @model the particle model
  31325. * @hidden
  31326. */
  31327. private _meshBuilder;
  31328. /**
  31329. * Returns a shape Vector3 array from positions float array
  31330. * @param positions float array
  31331. * @returns a vector3 array
  31332. * @hidden
  31333. */
  31334. private _posToShape;
  31335. /**
  31336. * Returns a shapeUV array from a float uvs (array deep copy)
  31337. * @param uvs as a float array
  31338. * @returns a shapeUV array
  31339. * @hidden
  31340. */
  31341. private _uvsToShapeUV;
  31342. /**
  31343. * Adds a new particle object in the particles array
  31344. * @param idx particle index in particles array
  31345. * @param id particle id
  31346. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  31347. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  31348. * @param model particle ModelShape object
  31349. * @param shapeId model shape identifier
  31350. * @param idxInShape index of the particle in the current model
  31351. * @param bInfo model bounding info object
  31352. * @param storage target storage array, if any
  31353. * @hidden
  31354. */
  31355. private _addParticle;
  31356. /**
  31357. * Adds some particles to the SPS from the model shape. Returns the shape id.
  31358. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  31359. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  31360. * @param nb (positive integer) the number of particles to be created from this model
  31361. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  31362. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  31363. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31364. * @returns the number of shapes in the system
  31365. */
  31366. addShape(mesh: Mesh, nb: number, options?: {
  31367. positionFunction?: any;
  31368. vertexFunction?: any;
  31369. storage?: [];
  31370. }): number;
  31371. /**
  31372. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  31373. * @hidden
  31374. */
  31375. private _rebuildParticle;
  31376. /**
  31377. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  31378. * @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.
  31379. * @returns the SPS.
  31380. */
  31381. rebuildMesh(reset?: boolean): SolidParticleSystem;
  31382. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  31383. * Returns an array with the removed particles.
  31384. * 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.
  31385. * The SPS can't be empty so at least one particle needs to remain in place.
  31386. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  31387. * @param start index of the first particle to remove
  31388. * @param end index of the last particle to remove (included)
  31389. * @returns an array populated with the removed particles
  31390. */
  31391. removeParticles(start: number, end: number): SolidParticle[];
  31392. /**
  31393. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  31394. * @param solidParticleArray an array populated with Solid Particles objects
  31395. * @returns the SPS
  31396. */
  31397. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  31398. /**
  31399. * Creates a new particle and modifies the SPS mesh geometry :
  31400. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  31401. * - calls _addParticle() to populate the particle array
  31402. * factorized code from addShape() and insertParticlesFromArray()
  31403. * @param idx particle index in the particles array
  31404. * @param i particle index in its shape
  31405. * @param modelShape particle ModelShape object
  31406. * @param shape shape vertex array
  31407. * @param meshInd shape indices array
  31408. * @param meshUV shape uv array
  31409. * @param meshCol shape color array
  31410. * @param meshNor shape normals array
  31411. * @param bbInfo shape bounding info
  31412. * @param storage target particle storage
  31413. * @options addShape() passed options
  31414. * @hidden
  31415. */
  31416. private _insertNewParticle;
  31417. /**
  31418. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  31419. * This method calls `updateParticle()` for each particle of the SPS.
  31420. * For an animated SPS, it is usually called within the render loop.
  31421. * 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.
  31422. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  31423. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  31424. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  31425. * @returns the SPS.
  31426. */
  31427. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  31428. /**
  31429. * Disposes the SPS.
  31430. */
  31431. dispose(): void;
  31432. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  31433. * idx is the particle index in the SPS
  31434. * faceId is the picked face index counted within this particle.
  31435. * Returns null if the pickInfo can't identify a picked particle.
  31436. * @param pickingInfo (PickingInfo object)
  31437. * @returns {idx: number, faceId: number} or null
  31438. */
  31439. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  31440. idx: number;
  31441. faceId: number;
  31442. }>;
  31443. /**
  31444. * Returns a SolidParticle object from its identifier : particle.id
  31445. * @param id (integer) the particle Id
  31446. * @returns the searched particle or null if not found in the SPS.
  31447. */
  31448. getParticleById(id: number): Nullable<SolidParticle>;
  31449. /**
  31450. * Returns a new array populated with the particles having the passed shapeId.
  31451. * @param shapeId (integer) the shape identifier
  31452. * @returns a new solid particle array
  31453. */
  31454. getParticlesByShapeId(shapeId: number): SolidParticle[];
  31455. /**
  31456. * Populates the passed array "ref" with the particles having the passed shapeId.
  31457. * @param shapeId the shape identifier
  31458. * @returns the SPS
  31459. * @param ref
  31460. */
  31461. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  31462. /**
  31463. * Computes the required SubMeshes according the materials assigned to the particles.
  31464. * @returns the solid particle system.
  31465. * Does nothing if called before the SPS mesh is built.
  31466. */
  31467. computeSubMeshes(): SolidParticleSystem;
  31468. /**
  31469. * Sorts the solid particles by material when MultiMaterial is enabled.
  31470. * Updates the indices32 array.
  31471. * Updates the indicesByMaterial array.
  31472. * Updates the mesh indices array.
  31473. * @returns the SPS
  31474. * @hidden
  31475. */
  31476. private _sortParticlesByMaterial;
  31477. /**
  31478. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  31479. * @hidden
  31480. */
  31481. private _setMaterialIndexesById;
  31482. /**
  31483. * Returns an array with unique values of Materials from the passed array
  31484. * @param array the material array to be checked and filtered
  31485. * @hidden
  31486. */
  31487. private _filterUniqueMaterialId;
  31488. /**
  31489. * Sets a new Standard Material as _defaultMaterial if not already set.
  31490. * @hidden
  31491. */
  31492. private _setDefaultMaterial;
  31493. /**
  31494. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  31495. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31496. * @returns the SPS.
  31497. */
  31498. refreshVisibleSize(): SolidParticleSystem;
  31499. /**
  31500. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  31501. * @param size the size (float) of the visibility box
  31502. * note : this doesn't lock the SPS mesh bounding box.
  31503. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31504. */
  31505. setVisibilityBox(size: number): void;
  31506. /**
  31507. * Gets whether the SPS as always visible or not
  31508. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31509. */
  31510. get isAlwaysVisible(): boolean;
  31511. /**
  31512. * Sets the SPS as always visible or not
  31513. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31514. */
  31515. set isAlwaysVisible(val: boolean);
  31516. /**
  31517. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31518. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31519. */
  31520. set isVisibilityBoxLocked(val: boolean);
  31521. /**
  31522. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31523. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31524. */
  31525. get isVisibilityBoxLocked(): boolean;
  31526. /**
  31527. * Tells to `setParticles()` to compute the particle rotations or not.
  31528. * Default value : true. The SPS is faster when it's set to false.
  31529. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31530. */
  31531. set computeParticleRotation(val: boolean);
  31532. /**
  31533. * Tells to `setParticles()` to compute the particle colors or not.
  31534. * Default value : true. The SPS is faster when it's set to false.
  31535. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31536. */
  31537. set computeParticleColor(val: boolean);
  31538. set computeParticleTexture(val: boolean);
  31539. /**
  31540. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  31541. * Default value : false. The SPS is faster when it's set to false.
  31542. * Note : the particle custom vertex positions aren't stored values.
  31543. */
  31544. set computeParticleVertex(val: boolean);
  31545. /**
  31546. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  31547. */
  31548. set computeBoundingBox(val: boolean);
  31549. /**
  31550. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  31551. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31552. * Default : `true`
  31553. */
  31554. set depthSortParticles(val: boolean);
  31555. /**
  31556. * Gets if `setParticles()` computes the particle rotations or not.
  31557. * Default value : true. The SPS is faster when it's set to false.
  31558. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31559. */
  31560. get computeParticleRotation(): boolean;
  31561. /**
  31562. * Gets if `setParticles()` computes the particle colors or not.
  31563. * Default value : true. The SPS is faster when it's set to false.
  31564. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31565. */
  31566. get computeParticleColor(): boolean;
  31567. /**
  31568. * Gets if `setParticles()` computes the particle textures or not.
  31569. * Default value : true. The SPS is faster when it's set to false.
  31570. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  31571. */
  31572. get computeParticleTexture(): boolean;
  31573. /**
  31574. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  31575. * Default value : false. The SPS is faster when it's set to false.
  31576. * Note : the particle custom vertex positions aren't stored values.
  31577. */
  31578. get computeParticleVertex(): boolean;
  31579. /**
  31580. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  31581. */
  31582. get computeBoundingBox(): boolean;
  31583. /**
  31584. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  31585. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31586. * Default : `true`
  31587. */
  31588. get depthSortParticles(): boolean;
  31589. /**
  31590. * Gets if the SPS is created as expandable at construction time.
  31591. * Default : `false`
  31592. */
  31593. get expandable(): boolean;
  31594. /**
  31595. * Gets if the SPS supports the Multi Materials
  31596. */
  31597. get multimaterialEnabled(): boolean;
  31598. /**
  31599. * Gets if the SPS uses the model materials for its own multimaterial.
  31600. */
  31601. get useModelMaterial(): boolean;
  31602. /**
  31603. * The SPS used material array.
  31604. */
  31605. get materials(): Material[];
  31606. /**
  31607. * Sets the SPS MultiMaterial from the passed materials.
  31608. * Note : the passed array is internally copied and not used then by reference.
  31609. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  31610. */
  31611. setMultiMaterial(materials: Material[]): void;
  31612. /**
  31613. * The SPS computed multimaterial object
  31614. */
  31615. get multimaterial(): MultiMaterial;
  31616. set multimaterial(mm: MultiMaterial);
  31617. /**
  31618. * If the subMeshes must be updated on the next call to setParticles()
  31619. */
  31620. get autoUpdateSubMeshes(): boolean;
  31621. set autoUpdateSubMeshes(val: boolean);
  31622. /**
  31623. * This function does nothing. It may be overwritten to set all the particle first values.
  31624. * The SPS doesn't call this function, you may have to call it by your own.
  31625. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31626. */
  31627. initParticles(): void;
  31628. /**
  31629. * This function does nothing. It may be overwritten to recycle a particle.
  31630. * The SPS doesn't call this function, you may have to call it by your own.
  31631. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31632. * @param particle The particle to recycle
  31633. * @returns the recycled particle
  31634. */
  31635. recycleParticle(particle: SolidParticle): SolidParticle;
  31636. /**
  31637. * Updates a particle : this function should be overwritten by the user.
  31638. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  31639. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31640. * @example : just set a particle position or velocity and recycle conditions
  31641. * @param particle The particle to update
  31642. * @returns the updated particle
  31643. */
  31644. updateParticle(particle: SolidParticle): SolidParticle;
  31645. /**
  31646. * Updates a vertex of a particle : it can be overwritten by the user.
  31647. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  31648. * @param particle the current particle
  31649. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  31650. * @param pt the index of the current vertex in the particle shape
  31651. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  31652. * @example : just set a vertex particle position or color
  31653. * @returns the sps
  31654. */
  31655. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  31656. /**
  31657. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  31658. * This does nothing and may be overwritten by the user.
  31659. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31660. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31661. * @param update the boolean update value actually passed to setParticles()
  31662. */
  31663. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31664. /**
  31665. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  31666. * This will be passed three parameters.
  31667. * This does nothing and may be overwritten by the user.
  31668. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31669. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31670. * @param update the boolean update value actually passed to setParticles()
  31671. */
  31672. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31673. }
  31674. }
  31675. declare module BABYLON {
  31676. /**
  31677. * Represents one particle of a solid particle system.
  31678. */
  31679. export class SolidParticle {
  31680. /**
  31681. * particle global index
  31682. */
  31683. idx: number;
  31684. /**
  31685. * particle identifier
  31686. */
  31687. id: number;
  31688. /**
  31689. * The color of the particle
  31690. */
  31691. color: Nullable<Color4>;
  31692. /**
  31693. * The world space position of the particle.
  31694. */
  31695. position: Vector3;
  31696. /**
  31697. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  31698. */
  31699. rotation: Vector3;
  31700. /**
  31701. * The world space rotation quaternion of the particle.
  31702. */
  31703. rotationQuaternion: Nullable<Quaternion>;
  31704. /**
  31705. * The scaling of the particle.
  31706. */
  31707. scaling: Vector3;
  31708. /**
  31709. * The uvs of the particle.
  31710. */
  31711. uvs: Vector4;
  31712. /**
  31713. * The current speed of the particle.
  31714. */
  31715. velocity: Vector3;
  31716. /**
  31717. * The pivot point in the particle local space.
  31718. */
  31719. pivot: Vector3;
  31720. /**
  31721. * Must the particle be translated from its pivot point in its local space ?
  31722. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  31723. * Default : false
  31724. */
  31725. translateFromPivot: boolean;
  31726. /**
  31727. * Is the particle active or not ?
  31728. */
  31729. alive: boolean;
  31730. /**
  31731. * Is the particle visible or not ?
  31732. */
  31733. isVisible: boolean;
  31734. /**
  31735. * Index of this particle in the global "positions" array (Internal use)
  31736. * @hidden
  31737. */
  31738. _pos: number;
  31739. /**
  31740. * @hidden Index of this particle in the global "indices" array (Internal use)
  31741. */
  31742. _ind: number;
  31743. /**
  31744. * @hidden ModelShape of this particle (Internal use)
  31745. */
  31746. _model: ModelShape;
  31747. /**
  31748. * ModelShape id of this particle
  31749. */
  31750. shapeId: number;
  31751. /**
  31752. * Index of the particle in its shape id
  31753. */
  31754. idxInShape: number;
  31755. /**
  31756. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  31757. */
  31758. _modelBoundingInfo: BoundingInfo;
  31759. /**
  31760. * @hidden Particle BoundingInfo object (Internal use)
  31761. */
  31762. _boundingInfo: BoundingInfo;
  31763. /**
  31764. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  31765. */
  31766. _sps: SolidParticleSystem;
  31767. /**
  31768. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  31769. */
  31770. _stillInvisible: boolean;
  31771. /**
  31772. * @hidden Last computed particle rotation matrix
  31773. */
  31774. _rotationMatrix: number[];
  31775. /**
  31776. * Parent particle Id, if any.
  31777. * Default null.
  31778. */
  31779. parentId: Nullable<number>;
  31780. /**
  31781. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  31782. */
  31783. materialIndex: Nullable<number>;
  31784. /**
  31785. * Custom object or properties.
  31786. */
  31787. props: Nullable<any>;
  31788. /**
  31789. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  31790. * The possible values are :
  31791. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31792. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31793. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31794. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31795. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31796. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  31797. * */
  31798. cullingStrategy: number;
  31799. /**
  31800. * @hidden Internal global position in the SPS.
  31801. */
  31802. _globalPosition: Vector3;
  31803. /**
  31804. * Creates a Solid Particle object.
  31805. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  31806. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  31807. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  31808. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  31809. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  31810. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  31811. * @param shapeId (integer) is the model shape identifier in the SPS.
  31812. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  31813. * @param sps defines the sps it is associated to
  31814. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  31815. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  31816. */
  31817. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  31818. /**
  31819. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  31820. * @param target the particle target
  31821. * @returns the current particle
  31822. */
  31823. copyToRef(target: SolidParticle): SolidParticle;
  31824. /**
  31825. * Legacy support, changed scale to scaling
  31826. */
  31827. get scale(): Vector3;
  31828. /**
  31829. * Legacy support, changed scale to scaling
  31830. */
  31831. set scale(scale: Vector3);
  31832. /**
  31833. * Legacy support, changed quaternion to rotationQuaternion
  31834. */
  31835. get quaternion(): Nullable<Quaternion>;
  31836. /**
  31837. * Legacy support, changed quaternion to rotationQuaternion
  31838. */
  31839. set quaternion(q: Nullable<Quaternion>);
  31840. /**
  31841. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  31842. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  31843. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  31844. * @returns true if it intersects
  31845. */
  31846. intersectsMesh(target: Mesh | SolidParticle): boolean;
  31847. /**
  31848. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  31849. * A particle is in the frustum if its bounding box intersects the frustum
  31850. * @param frustumPlanes defines the frustum to test
  31851. * @returns true if the particle is in the frustum planes
  31852. */
  31853. isInFrustum(frustumPlanes: Plane[]): boolean;
  31854. /**
  31855. * get the rotation matrix of the particle
  31856. * @hidden
  31857. */
  31858. getRotationMatrix(m: Matrix): void;
  31859. }
  31860. /**
  31861. * Represents the shape of the model used by one particle of a solid particle system.
  31862. * SPS internal tool, don't use it manually.
  31863. */
  31864. export class ModelShape {
  31865. /**
  31866. * The shape id
  31867. * @hidden
  31868. */
  31869. shapeID: number;
  31870. /**
  31871. * flat array of model positions (internal use)
  31872. * @hidden
  31873. */
  31874. _shape: Vector3[];
  31875. /**
  31876. * flat array of model UVs (internal use)
  31877. * @hidden
  31878. */
  31879. _shapeUV: number[];
  31880. /**
  31881. * color array of the model
  31882. * @hidden
  31883. */
  31884. _shapeColors: number[];
  31885. /**
  31886. * indices array of the model
  31887. * @hidden
  31888. */
  31889. _indices: number[];
  31890. /**
  31891. * normals array of the model
  31892. * @hidden
  31893. */
  31894. _normals: number[];
  31895. /**
  31896. * length of the shape in the model indices array (internal use)
  31897. * @hidden
  31898. */
  31899. _indicesLength: number;
  31900. /**
  31901. * Custom position function (internal use)
  31902. * @hidden
  31903. */
  31904. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  31905. /**
  31906. * Custom vertex function (internal use)
  31907. * @hidden
  31908. */
  31909. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  31910. /**
  31911. * Model material (internal use)
  31912. * @hidden
  31913. */
  31914. _material: Nullable<Material>;
  31915. /**
  31916. * 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.
  31917. * SPS internal tool, don't use it manually.
  31918. * @hidden
  31919. */
  31920. 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>);
  31921. }
  31922. /**
  31923. * Represents a Depth Sorted Particle in the solid particle system.
  31924. * @hidden
  31925. */
  31926. export class DepthSortedParticle {
  31927. /**
  31928. * Particle index
  31929. */
  31930. idx: number;
  31931. /**
  31932. * Index of the particle in the "indices" array
  31933. */
  31934. ind: number;
  31935. /**
  31936. * Length of the particle shape in the "indices" array
  31937. */
  31938. indicesLength: number;
  31939. /**
  31940. * Squared distance from the particle to the camera
  31941. */
  31942. sqDistance: number;
  31943. /**
  31944. * Material index when used with MultiMaterials
  31945. */
  31946. materialIndex: number;
  31947. /**
  31948. * Creates a new sorted particle
  31949. * @param materialIndex
  31950. */
  31951. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  31952. }
  31953. /**
  31954. * Represents a solid particle vertex
  31955. */
  31956. export class SolidParticleVertex {
  31957. /**
  31958. * Vertex position
  31959. */
  31960. position: Vector3;
  31961. /**
  31962. * Vertex color
  31963. */
  31964. color: Color4;
  31965. /**
  31966. * Vertex UV
  31967. */
  31968. uv: Vector2;
  31969. /**
  31970. * Creates a new solid particle vertex
  31971. */
  31972. constructor();
  31973. /** Vertex x coordinate */
  31974. get x(): number;
  31975. set x(val: number);
  31976. /** Vertex y coordinate */
  31977. get y(): number;
  31978. set y(val: number);
  31979. /** Vertex z coordinate */
  31980. get z(): number;
  31981. set z(val: number);
  31982. }
  31983. }
  31984. declare module BABYLON {
  31985. /**
  31986. * @hidden
  31987. */
  31988. export class _MeshCollisionData {
  31989. _checkCollisions: boolean;
  31990. _collisionMask: number;
  31991. _collisionGroup: number;
  31992. _surroundingMeshes: Nullable<AbstractMesh[]>;
  31993. _collider: Nullable<Collider>;
  31994. _oldPositionForCollisions: Vector3;
  31995. _diffPositionForCollisions: Vector3;
  31996. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  31997. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  31998. _collisionResponse: boolean;
  31999. }
  32000. }
  32001. declare module BABYLON {
  32002. /** @hidden */
  32003. class _FacetDataStorage {
  32004. facetPositions: Vector3[];
  32005. facetNormals: Vector3[];
  32006. facetPartitioning: number[][];
  32007. facetNb: number;
  32008. partitioningSubdivisions: number;
  32009. partitioningBBoxRatio: number;
  32010. facetDataEnabled: boolean;
  32011. facetParameters: any;
  32012. bbSize: Vector3;
  32013. subDiv: {
  32014. max: number;
  32015. X: number;
  32016. Y: number;
  32017. Z: number;
  32018. };
  32019. facetDepthSort: boolean;
  32020. facetDepthSortEnabled: boolean;
  32021. depthSortedIndices: IndicesArray;
  32022. depthSortedFacets: {
  32023. ind: number;
  32024. sqDistance: number;
  32025. }[];
  32026. facetDepthSortFunction: (f1: {
  32027. ind: number;
  32028. sqDistance: number;
  32029. }, f2: {
  32030. ind: number;
  32031. sqDistance: number;
  32032. }) => number;
  32033. facetDepthSortFrom: Vector3;
  32034. facetDepthSortOrigin: Vector3;
  32035. invertedMatrix: Matrix;
  32036. }
  32037. /**
  32038. * @hidden
  32039. **/
  32040. class _InternalAbstractMeshDataInfo {
  32041. _hasVertexAlpha: boolean;
  32042. _useVertexColors: boolean;
  32043. _numBoneInfluencers: number;
  32044. _applyFog: boolean;
  32045. _receiveShadows: boolean;
  32046. _facetData: _FacetDataStorage;
  32047. _visibility: number;
  32048. _skeleton: Nullable<Skeleton>;
  32049. _layerMask: number;
  32050. _computeBonesUsingShaders: boolean;
  32051. _isActive: boolean;
  32052. _onlyForInstances: boolean;
  32053. _isActiveIntermediate: boolean;
  32054. _onlyForInstancesIntermediate: boolean;
  32055. _actAsRegularMesh: boolean;
  32056. }
  32057. /**
  32058. * Class used to store all common mesh properties
  32059. */
  32060. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  32061. /** No occlusion */
  32062. static OCCLUSION_TYPE_NONE: number;
  32063. /** Occlusion set to optimisitic */
  32064. static OCCLUSION_TYPE_OPTIMISTIC: number;
  32065. /** Occlusion set to strict */
  32066. static OCCLUSION_TYPE_STRICT: number;
  32067. /** Use an accurante occlusion algorithm */
  32068. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  32069. /** Use a conservative occlusion algorithm */
  32070. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  32071. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  32072. * Test order :
  32073. * Is the bounding sphere outside the frustum ?
  32074. * If not, are the bounding box vertices outside the frustum ?
  32075. * It not, then the cullable object is in the frustum.
  32076. */
  32077. static readonly CULLINGSTRATEGY_STANDARD: number;
  32078. /** Culling strategy : Bounding Sphere Only.
  32079. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  32080. * It's also less accurate than the standard because some not visible objects can still be selected.
  32081. * Test : is the bounding sphere outside the frustum ?
  32082. * If not, then the cullable object is in the frustum.
  32083. */
  32084. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  32085. /** Culling strategy : Optimistic Inclusion.
  32086. * This in an inclusion test first, then the standard exclusion test.
  32087. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  32088. * 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.
  32089. * Anyway, it's as accurate as the standard strategy.
  32090. * Test :
  32091. * Is the cullable object bounding sphere center in the frustum ?
  32092. * If not, apply the default culling strategy.
  32093. */
  32094. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  32095. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  32096. * This in an inclusion test first, then the bounding sphere only exclusion test.
  32097. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  32098. * 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.
  32099. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  32100. * Test :
  32101. * Is the cullable object bounding sphere center in the frustum ?
  32102. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  32103. */
  32104. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  32105. /**
  32106. * No billboard
  32107. */
  32108. static get BILLBOARDMODE_NONE(): number;
  32109. /** Billboard on X axis */
  32110. static get BILLBOARDMODE_X(): number;
  32111. /** Billboard on Y axis */
  32112. static get BILLBOARDMODE_Y(): number;
  32113. /** Billboard on Z axis */
  32114. static get BILLBOARDMODE_Z(): number;
  32115. /** Billboard on all axes */
  32116. static get BILLBOARDMODE_ALL(): number;
  32117. /** Billboard on using position instead of orientation */
  32118. static get BILLBOARDMODE_USE_POSITION(): number;
  32119. /** @hidden */
  32120. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  32121. /**
  32122. * The culling strategy to use to check whether the mesh must be rendered or not.
  32123. * This value can be changed at any time and will be used on the next render mesh selection.
  32124. * The possible values are :
  32125. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32126. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32127. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32128. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32129. * Please read each static variable documentation to get details about the culling process.
  32130. * */
  32131. cullingStrategy: number;
  32132. /**
  32133. * Gets the number of facets in the mesh
  32134. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32135. */
  32136. get facetNb(): number;
  32137. /**
  32138. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  32139. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32140. */
  32141. get partitioningSubdivisions(): number;
  32142. set partitioningSubdivisions(nb: number);
  32143. /**
  32144. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  32145. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  32146. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32147. */
  32148. get partitioningBBoxRatio(): number;
  32149. set partitioningBBoxRatio(ratio: number);
  32150. /**
  32151. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  32152. * Works only for updatable meshes.
  32153. * Doesn't work with multi-materials
  32154. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32155. */
  32156. get mustDepthSortFacets(): boolean;
  32157. set mustDepthSortFacets(sort: boolean);
  32158. /**
  32159. * The location (Vector3) where the facet depth sort must be computed from.
  32160. * By default, the active camera position.
  32161. * Used only when facet depth sort is enabled
  32162. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32163. */
  32164. get facetDepthSortFrom(): Vector3;
  32165. set facetDepthSortFrom(location: Vector3);
  32166. /**
  32167. * gets a boolean indicating if facetData is enabled
  32168. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32169. */
  32170. get isFacetDataEnabled(): boolean;
  32171. /** @hidden */
  32172. _updateNonUniformScalingState(value: boolean): boolean;
  32173. /**
  32174. * An event triggered when this mesh collides with another one
  32175. */
  32176. onCollideObservable: Observable<AbstractMesh>;
  32177. /** Set a function to call when this mesh collides with another one */
  32178. set onCollide(callback: () => void);
  32179. /**
  32180. * An event triggered when the collision's position changes
  32181. */
  32182. onCollisionPositionChangeObservable: Observable<Vector3>;
  32183. /** Set a function to call when the collision's position changes */
  32184. set onCollisionPositionChange(callback: () => void);
  32185. /**
  32186. * An event triggered when material is changed
  32187. */
  32188. onMaterialChangedObservable: Observable<AbstractMesh>;
  32189. /**
  32190. * Gets or sets the orientation for POV movement & rotation
  32191. */
  32192. definedFacingForward: boolean;
  32193. /** @hidden */
  32194. _occlusionQuery: Nullable<WebGLQuery>;
  32195. /** @hidden */
  32196. _renderingGroup: Nullable<RenderingGroup>;
  32197. /**
  32198. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32199. */
  32200. get visibility(): number;
  32201. /**
  32202. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32203. */
  32204. set visibility(value: number);
  32205. /** Gets or sets the alpha index used to sort transparent meshes
  32206. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  32207. */
  32208. alphaIndex: number;
  32209. /**
  32210. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  32211. */
  32212. isVisible: boolean;
  32213. /**
  32214. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  32215. */
  32216. isPickable: boolean;
  32217. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  32218. showSubMeshesBoundingBox: boolean;
  32219. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  32220. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  32221. */
  32222. isBlocker: boolean;
  32223. /**
  32224. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  32225. */
  32226. enablePointerMoveEvents: boolean;
  32227. private _renderingGroupId;
  32228. /**
  32229. * Specifies the rendering group id for this mesh (0 by default)
  32230. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  32231. */
  32232. get renderingGroupId(): number;
  32233. set renderingGroupId(value: number);
  32234. private _material;
  32235. /** Gets or sets current material */
  32236. get material(): Nullable<Material>;
  32237. set material(value: Nullable<Material>);
  32238. /**
  32239. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  32240. * @see https://doc.babylonjs.com/babylon101/shadows
  32241. */
  32242. get receiveShadows(): boolean;
  32243. set receiveShadows(value: boolean);
  32244. /** Defines color to use when rendering outline */
  32245. outlineColor: Color3;
  32246. /** Define width to use when rendering outline */
  32247. outlineWidth: number;
  32248. /** Defines color to use when rendering overlay */
  32249. overlayColor: Color3;
  32250. /** Defines alpha to use when rendering overlay */
  32251. overlayAlpha: number;
  32252. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  32253. get hasVertexAlpha(): boolean;
  32254. set hasVertexAlpha(value: boolean);
  32255. /** 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) */
  32256. get useVertexColors(): boolean;
  32257. set useVertexColors(value: boolean);
  32258. /**
  32259. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  32260. */
  32261. get computeBonesUsingShaders(): boolean;
  32262. set computeBonesUsingShaders(value: boolean);
  32263. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  32264. get numBoneInfluencers(): number;
  32265. set numBoneInfluencers(value: number);
  32266. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  32267. get applyFog(): boolean;
  32268. set applyFog(value: boolean);
  32269. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  32270. useOctreeForRenderingSelection: boolean;
  32271. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  32272. useOctreeForPicking: boolean;
  32273. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  32274. useOctreeForCollisions: boolean;
  32275. /**
  32276. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  32277. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  32278. */
  32279. get layerMask(): number;
  32280. set layerMask(value: number);
  32281. /**
  32282. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  32283. */
  32284. alwaysSelectAsActiveMesh: boolean;
  32285. /**
  32286. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  32287. */
  32288. doNotSyncBoundingInfo: boolean;
  32289. /**
  32290. * Gets or sets the current action manager
  32291. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  32292. */
  32293. actionManager: Nullable<AbstractActionManager>;
  32294. private _meshCollisionData;
  32295. /**
  32296. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  32297. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32298. */
  32299. ellipsoid: Vector3;
  32300. /**
  32301. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  32302. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32303. */
  32304. ellipsoidOffset: Vector3;
  32305. /**
  32306. * Gets or sets a collision mask used to mask collisions (default is -1).
  32307. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32308. */
  32309. get collisionMask(): number;
  32310. set collisionMask(mask: number);
  32311. /**
  32312. * Gets or sets a collision response flag (default is true).
  32313. * when collisionResponse is false, events are still triggered but colliding entity has no response
  32314. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  32315. * to respond to the collision.
  32316. */
  32317. get collisionResponse(): boolean;
  32318. set collisionResponse(response: boolean);
  32319. /**
  32320. * Gets or sets the current collision group mask (-1 by default).
  32321. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32322. */
  32323. get collisionGroup(): number;
  32324. set collisionGroup(mask: number);
  32325. /**
  32326. * Gets or sets current surrounding meshes (null by default).
  32327. *
  32328. * By default collision detection is tested against every mesh in the scene.
  32329. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  32330. * meshes will be tested for the collision.
  32331. *
  32332. * Note: if set to an empty array no collision will happen when this mesh is moved.
  32333. */
  32334. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  32335. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  32336. /**
  32337. * Defines edge width used when edgesRenderer is enabled
  32338. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32339. */
  32340. edgesWidth: number;
  32341. /**
  32342. * Defines edge color used when edgesRenderer is enabled
  32343. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32344. */
  32345. edgesColor: Color4;
  32346. /** @hidden */
  32347. _edgesRenderer: Nullable<IEdgesRenderer>;
  32348. /** @hidden */
  32349. _masterMesh: Nullable<AbstractMesh>;
  32350. /** @hidden */
  32351. _boundingInfo: Nullable<BoundingInfo>;
  32352. /** @hidden */
  32353. _renderId: number;
  32354. /**
  32355. * Gets or sets the list of subMeshes
  32356. * @see https://doc.babylonjs.com/how_to/multi_materials
  32357. */
  32358. subMeshes: SubMesh[];
  32359. /** @hidden */
  32360. _intersectionsInProgress: AbstractMesh[];
  32361. /** @hidden */
  32362. _unIndexed: boolean;
  32363. /** @hidden */
  32364. _lightSources: Light[];
  32365. /** Gets the list of lights affecting that mesh */
  32366. get lightSources(): Light[];
  32367. /** @hidden */
  32368. get _positions(): Nullable<Vector3[]>;
  32369. /** @hidden */
  32370. _waitingData: {
  32371. lods: Nullable<any>;
  32372. actions: Nullable<any>;
  32373. freezeWorldMatrix: Nullable<boolean>;
  32374. };
  32375. /** @hidden */
  32376. _bonesTransformMatrices: Nullable<Float32Array>;
  32377. /** @hidden */
  32378. _transformMatrixTexture: Nullable<RawTexture>;
  32379. /**
  32380. * Gets or sets a skeleton to apply skining transformations
  32381. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32382. */
  32383. set skeleton(value: Nullable<Skeleton>);
  32384. get skeleton(): Nullable<Skeleton>;
  32385. /**
  32386. * An event triggered when the mesh is rebuilt.
  32387. */
  32388. onRebuildObservable: Observable<AbstractMesh>;
  32389. /**
  32390. * Creates a new AbstractMesh
  32391. * @param name defines the name of the mesh
  32392. * @param scene defines the hosting scene
  32393. */
  32394. constructor(name: string, scene?: Nullable<Scene>);
  32395. /**
  32396. * Returns the string "AbstractMesh"
  32397. * @returns "AbstractMesh"
  32398. */
  32399. getClassName(): string;
  32400. /**
  32401. * Gets a string representation of the current mesh
  32402. * @param fullDetails defines a boolean indicating if full details must be included
  32403. * @returns a string representation of the current mesh
  32404. */
  32405. toString(fullDetails?: boolean): string;
  32406. /**
  32407. * @hidden
  32408. */
  32409. protected _getEffectiveParent(): Nullable<Node>;
  32410. /** @hidden */
  32411. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32412. /** @hidden */
  32413. _rebuild(): void;
  32414. /** @hidden */
  32415. _resyncLightSources(): void;
  32416. /** @hidden */
  32417. _resyncLightSource(light: Light): void;
  32418. /** @hidden */
  32419. _unBindEffect(): void;
  32420. /** @hidden */
  32421. _removeLightSource(light: Light, dispose: boolean): void;
  32422. private _markSubMeshesAsDirty;
  32423. /** @hidden */
  32424. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  32425. /** @hidden */
  32426. _markSubMeshesAsAttributesDirty(): void;
  32427. /** @hidden */
  32428. _markSubMeshesAsMiscDirty(): void;
  32429. /**
  32430. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  32431. */
  32432. get scaling(): Vector3;
  32433. set scaling(newScaling: Vector3);
  32434. /**
  32435. * Returns true if the mesh is blocked. Implemented by child classes
  32436. */
  32437. get isBlocked(): boolean;
  32438. /**
  32439. * Returns the mesh itself by default. Implemented by child classes
  32440. * @param camera defines the camera to use to pick the right LOD level
  32441. * @returns the currentAbstractMesh
  32442. */
  32443. getLOD(camera: Camera): Nullable<AbstractMesh>;
  32444. /**
  32445. * Returns 0 by default. Implemented by child classes
  32446. * @returns an integer
  32447. */
  32448. getTotalVertices(): number;
  32449. /**
  32450. * Returns a positive integer : the total number of indices in this mesh geometry.
  32451. * @returns the numner of indices or zero if the mesh has no geometry.
  32452. */
  32453. getTotalIndices(): number;
  32454. /**
  32455. * Returns null by default. Implemented by child classes
  32456. * @returns null
  32457. */
  32458. getIndices(): Nullable<IndicesArray>;
  32459. /**
  32460. * Returns the array of the requested vertex data kind. Implemented by child classes
  32461. * @param kind defines the vertex data kind to use
  32462. * @returns null
  32463. */
  32464. getVerticesData(kind: string): Nullable<FloatArray>;
  32465. /**
  32466. * Sets the vertex data of the mesh geometry for the requested `kind`.
  32467. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  32468. * Note that a new underlying VertexBuffer object is created each call.
  32469. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  32470. * @param kind defines vertex data kind:
  32471. * * VertexBuffer.PositionKind
  32472. * * VertexBuffer.UVKind
  32473. * * VertexBuffer.UV2Kind
  32474. * * VertexBuffer.UV3Kind
  32475. * * VertexBuffer.UV4Kind
  32476. * * VertexBuffer.UV5Kind
  32477. * * VertexBuffer.UV6Kind
  32478. * * VertexBuffer.ColorKind
  32479. * * VertexBuffer.MatricesIndicesKind
  32480. * * VertexBuffer.MatricesIndicesExtraKind
  32481. * * VertexBuffer.MatricesWeightsKind
  32482. * * VertexBuffer.MatricesWeightsExtraKind
  32483. * @param data defines the data source
  32484. * @param updatable defines if the data must be flagged as updatable (or static)
  32485. * @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
  32486. * @returns the current mesh
  32487. */
  32488. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32489. /**
  32490. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  32491. * If the mesh has no geometry, it is simply returned as it is.
  32492. * @param kind defines vertex data kind:
  32493. * * VertexBuffer.PositionKind
  32494. * * VertexBuffer.UVKind
  32495. * * VertexBuffer.UV2Kind
  32496. * * VertexBuffer.UV3Kind
  32497. * * VertexBuffer.UV4Kind
  32498. * * VertexBuffer.UV5Kind
  32499. * * VertexBuffer.UV6Kind
  32500. * * VertexBuffer.ColorKind
  32501. * * VertexBuffer.MatricesIndicesKind
  32502. * * VertexBuffer.MatricesIndicesExtraKind
  32503. * * VertexBuffer.MatricesWeightsKind
  32504. * * VertexBuffer.MatricesWeightsExtraKind
  32505. * @param data defines the data source
  32506. * @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
  32507. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  32508. * @returns the current mesh
  32509. */
  32510. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32511. /**
  32512. * Sets the mesh indices,
  32513. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  32514. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  32515. * @param totalVertices Defines the total number of vertices
  32516. * @returns the current mesh
  32517. */
  32518. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  32519. /**
  32520. * Gets a boolean indicating if specific vertex data is present
  32521. * @param kind defines the vertex data kind to use
  32522. * @returns true is data kind is present
  32523. */
  32524. isVerticesDataPresent(kind: string): boolean;
  32525. /**
  32526. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  32527. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  32528. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  32529. * @returns a BoundingInfo
  32530. */
  32531. getBoundingInfo(): BoundingInfo;
  32532. /**
  32533. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  32534. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  32535. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  32536. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  32537. * @returns the current mesh
  32538. */
  32539. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  32540. /**
  32541. * Overwrite the current bounding info
  32542. * @param boundingInfo defines the new bounding info
  32543. * @returns the current mesh
  32544. */
  32545. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  32546. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  32547. get useBones(): boolean;
  32548. /** @hidden */
  32549. _preActivate(): void;
  32550. /** @hidden */
  32551. _preActivateForIntermediateRendering(renderId: number): void;
  32552. /** @hidden */
  32553. _activate(renderId: number, intermediateRendering: boolean): boolean;
  32554. /** @hidden */
  32555. _postActivate(): void;
  32556. /** @hidden */
  32557. _freeze(): void;
  32558. /** @hidden */
  32559. _unFreeze(): void;
  32560. /**
  32561. * Gets the current world matrix
  32562. * @returns a Matrix
  32563. */
  32564. getWorldMatrix(): Matrix;
  32565. /** @hidden */
  32566. _getWorldMatrixDeterminant(): number;
  32567. /**
  32568. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  32569. */
  32570. get isAnInstance(): boolean;
  32571. /**
  32572. * Gets a boolean indicating if this mesh has instances
  32573. */
  32574. get hasInstances(): boolean;
  32575. /**
  32576. * Gets a boolean indicating if this mesh has thin instances
  32577. */
  32578. get hasThinInstances(): boolean;
  32579. /**
  32580. * Perform relative position change from the point of view of behind the front of the mesh.
  32581. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32582. * Supports definition of mesh facing forward or backward
  32583. * @param amountRight defines the distance on the right axis
  32584. * @param amountUp defines the distance on the up axis
  32585. * @param amountForward defines the distance on the forward axis
  32586. * @returns the current mesh
  32587. */
  32588. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  32589. /**
  32590. * Calculate relative position change from the point of view of behind the front of the mesh.
  32591. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32592. * Supports definition of mesh facing forward or backward
  32593. * @param amountRight defines the distance on the right axis
  32594. * @param amountUp defines the distance on the up axis
  32595. * @param amountForward defines the distance on the forward axis
  32596. * @returns the new displacement vector
  32597. */
  32598. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  32599. /**
  32600. * Perform relative rotation change from the point of view of behind the front of the mesh.
  32601. * Supports definition of mesh facing forward or backward
  32602. * @param flipBack defines the flip
  32603. * @param twirlClockwise defines the twirl
  32604. * @param tiltRight defines the tilt
  32605. * @returns the current mesh
  32606. */
  32607. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  32608. /**
  32609. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  32610. * Supports definition of mesh facing forward or backward.
  32611. * @param flipBack defines the flip
  32612. * @param twirlClockwise defines the twirl
  32613. * @param tiltRight defines the tilt
  32614. * @returns the new rotation vector
  32615. */
  32616. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  32617. /**
  32618. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32619. * This means the mesh underlying bounding box and sphere are recomputed.
  32620. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32621. * @returns the current mesh
  32622. */
  32623. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  32624. /** @hidden */
  32625. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  32626. /** @hidden */
  32627. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  32628. /** @hidden */
  32629. _updateBoundingInfo(): AbstractMesh;
  32630. /** @hidden */
  32631. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  32632. /** @hidden */
  32633. protected _afterComputeWorldMatrix(): void;
  32634. /** @hidden */
  32635. get _effectiveMesh(): AbstractMesh;
  32636. /**
  32637. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32638. * A mesh is in the frustum if its bounding box intersects the frustum
  32639. * @param frustumPlanes defines the frustum to test
  32640. * @returns true if the mesh is in the frustum planes
  32641. */
  32642. isInFrustum(frustumPlanes: Plane[]): boolean;
  32643. /**
  32644. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  32645. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  32646. * @param frustumPlanes defines the frustum to test
  32647. * @returns true if the mesh is completely in the frustum planes
  32648. */
  32649. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  32650. /**
  32651. * True if the mesh intersects another mesh or a SolidParticle object
  32652. * @param mesh defines a target mesh or SolidParticle to test
  32653. * @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)
  32654. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  32655. * @returns true if there is an intersection
  32656. */
  32657. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  32658. /**
  32659. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  32660. * @param point defines the point to test
  32661. * @returns true if there is an intersection
  32662. */
  32663. intersectsPoint(point: Vector3): boolean;
  32664. /**
  32665. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  32666. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32667. */
  32668. get checkCollisions(): boolean;
  32669. set checkCollisions(collisionEnabled: boolean);
  32670. /**
  32671. * Gets Collider object used to compute collisions (not physics)
  32672. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32673. */
  32674. get collider(): Nullable<Collider>;
  32675. /**
  32676. * Move the mesh using collision engine
  32677. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32678. * @param displacement defines the requested displacement vector
  32679. * @returns the current mesh
  32680. */
  32681. moveWithCollisions(displacement: Vector3): AbstractMesh;
  32682. private _onCollisionPositionChange;
  32683. /** @hidden */
  32684. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  32685. /** @hidden */
  32686. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  32687. /** @hidden */
  32688. _checkCollision(collider: Collider): AbstractMesh;
  32689. /** @hidden */
  32690. _generatePointsArray(): boolean;
  32691. /**
  32692. * Checks if the passed Ray intersects with the mesh
  32693. * @param ray defines the ray to use
  32694. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  32695. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32696. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  32697. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  32698. * @returns the picking info
  32699. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  32700. */
  32701. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  32702. /**
  32703. * Clones the current mesh
  32704. * @param name defines the mesh name
  32705. * @param newParent defines the new mesh parent
  32706. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  32707. * @returns the new mesh
  32708. */
  32709. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  32710. /**
  32711. * Disposes all the submeshes of the current meshnp
  32712. * @returns the current mesh
  32713. */
  32714. releaseSubMeshes(): AbstractMesh;
  32715. /**
  32716. * Releases resources associated with this abstract mesh.
  32717. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32718. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32719. */
  32720. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32721. /**
  32722. * Adds the passed mesh as a child to the current mesh
  32723. * @param mesh defines the child mesh
  32724. * @returns the current mesh
  32725. */
  32726. addChild(mesh: AbstractMesh): AbstractMesh;
  32727. /**
  32728. * Removes the passed mesh from the current mesh children list
  32729. * @param mesh defines the child mesh
  32730. * @returns the current mesh
  32731. */
  32732. removeChild(mesh: AbstractMesh): AbstractMesh;
  32733. /** @hidden */
  32734. private _initFacetData;
  32735. /**
  32736. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  32737. * This method can be called within the render loop.
  32738. * 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
  32739. * @returns the current mesh
  32740. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32741. */
  32742. updateFacetData(): AbstractMesh;
  32743. /**
  32744. * Returns the facetLocalNormals array.
  32745. * The normals are expressed in the mesh local spac
  32746. * @returns an array of Vector3
  32747. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32748. */
  32749. getFacetLocalNormals(): Vector3[];
  32750. /**
  32751. * Returns the facetLocalPositions array.
  32752. * The facet positions are expressed in the mesh local space
  32753. * @returns an array of Vector3
  32754. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32755. */
  32756. getFacetLocalPositions(): Vector3[];
  32757. /**
  32758. * Returns the facetLocalPartioning array
  32759. * @returns an array of array of numbers
  32760. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32761. */
  32762. getFacetLocalPartitioning(): number[][];
  32763. /**
  32764. * Returns the i-th facet position in the world system.
  32765. * This method allocates a new Vector3 per call
  32766. * @param i defines the facet index
  32767. * @returns a new Vector3
  32768. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32769. */
  32770. getFacetPosition(i: number): Vector3;
  32771. /**
  32772. * Sets the reference Vector3 with the i-th facet position in the world system
  32773. * @param i defines the facet index
  32774. * @param ref defines the target vector
  32775. * @returns the current mesh
  32776. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32777. */
  32778. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  32779. /**
  32780. * Returns the i-th facet normal in the world system.
  32781. * This method allocates a new Vector3 per call
  32782. * @param i defines the facet index
  32783. * @returns a new Vector3
  32784. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32785. */
  32786. getFacetNormal(i: number): Vector3;
  32787. /**
  32788. * Sets the reference Vector3 with the i-th facet normal in the world system
  32789. * @param i defines the facet index
  32790. * @param ref defines the target vector
  32791. * @returns the current mesh
  32792. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32793. */
  32794. getFacetNormalToRef(i: number, ref: Vector3): this;
  32795. /**
  32796. * 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)
  32797. * @param x defines x coordinate
  32798. * @param y defines y coordinate
  32799. * @param z defines z coordinate
  32800. * @returns the array of facet indexes
  32801. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32802. */
  32803. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  32804. /**
  32805. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  32806. * @param projected sets as the (x,y,z) world projection on the facet
  32807. * @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
  32808. * @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
  32809. * @param x defines x coordinate
  32810. * @param y defines y coordinate
  32811. * @param z defines z coordinate
  32812. * @returns the face index if found (or null instead)
  32813. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32814. */
  32815. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32816. /**
  32817. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  32818. * @param projected sets as the (x,y,z) local projection on the facet
  32819. * @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
  32820. * @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
  32821. * @param x defines x coordinate
  32822. * @param y defines y coordinate
  32823. * @param z defines z coordinate
  32824. * @returns the face index if found (or null instead)
  32825. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32826. */
  32827. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32828. /**
  32829. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  32830. * @returns the parameters
  32831. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32832. */
  32833. getFacetDataParameters(): any;
  32834. /**
  32835. * Disables the feature FacetData and frees the related memory
  32836. * @returns the current mesh
  32837. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32838. */
  32839. disableFacetData(): AbstractMesh;
  32840. /**
  32841. * Updates the AbstractMesh indices array
  32842. * @param indices defines the data source
  32843. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32844. * @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)
  32845. * @returns the current mesh
  32846. */
  32847. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32848. /**
  32849. * Creates new normals data for the mesh
  32850. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  32851. * @returns the current mesh
  32852. */
  32853. createNormals(updatable: boolean): AbstractMesh;
  32854. /**
  32855. * Align the mesh with a normal
  32856. * @param normal defines the normal to use
  32857. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  32858. * @returns the current mesh
  32859. */
  32860. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  32861. /** @hidden */
  32862. _checkOcclusionQuery(): boolean;
  32863. /**
  32864. * Disables the mesh edge rendering mode
  32865. * @returns the currentAbstractMesh
  32866. */
  32867. disableEdgesRendering(): AbstractMesh;
  32868. /**
  32869. * Enables the edge rendering mode on the mesh.
  32870. * This mode makes the mesh edges visible
  32871. * @param epsilon defines the maximal distance between two angles to detect a face
  32872. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  32873. * @returns the currentAbstractMesh
  32874. * @see https://www.babylonjs-playground.com/#19O9TU#0
  32875. */
  32876. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  32877. /**
  32878. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  32879. * @returns an array of particle systems in the scene that use the mesh as an emitter
  32880. */
  32881. getConnectedParticleSystems(): IParticleSystem[];
  32882. }
  32883. }
  32884. declare module BABYLON {
  32885. /**
  32886. * Interface used to define ActionEvent
  32887. */
  32888. export interface IActionEvent {
  32889. /** The mesh or sprite that triggered the action */
  32890. source: any;
  32891. /** The X mouse cursor position at the time of the event */
  32892. pointerX: number;
  32893. /** The Y mouse cursor position at the time of the event */
  32894. pointerY: number;
  32895. /** The mesh that is currently pointed at (can be null) */
  32896. meshUnderPointer: Nullable<AbstractMesh>;
  32897. /** the original (browser) event that triggered the ActionEvent */
  32898. sourceEvent?: any;
  32899. /** additional data for the event */
  32900. additionalData?: any;
  32901. }
  32902. /**
  32903. * ActionEvent is the event being sent when an action is triggered.
  32904. */
  32905. export class ActionEvent implements IActionEvent {
  32906. /** The mesh or sprite that triggered the action */
  32907. source: any;
  32908. /** The X mouse cursor position at the time of the event */
  32909. pointerX: number;
  32910. /** The Y mouse cursor position at the time of the event */
  32911. pointerY: number;
  32912. /** The mesh that is currently pointed at (can be null) */
  32913. meshUnderPointer: Nullable<AbstractMesh>;
  32914. /** the original (browser) event that triggered the ActionEvent */
  32915. sourceEvent?: any;
  32916. /** additional data for the event */
  32917. additionalData?: any;
  32918. /**
  32919. * Creates a new ActionEvent
  32920. * @param source The mesh or sprite that triggered the action
  32921. * @param pointerX The X mouse cursor position at the time of the event
  32922. * @param pointerY The Y mouse cursor position at the time of the event
  32923. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  32924. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  32925. * @param additionalData additional data for the event
  32926. */
  32927. constructor(
  32928. /** The mesh or sprite that triggered the action */
  32929. source: any,
  32930. /** The X mouse cursor position at the time of the event */
  32931. pointerX: number,
  32932. /** The Y mouse cursor position at the time of the event */
  32933. pointerY: number,
  32934. /** The mesh that is currently pointed at (can be null) */
  32935. meshUnderPointer: Nullable<AbstractMesh>,
  32936. /** the original (browser) event that triggered the ActionEvent */
  32937. sourceEvent?: any,
  32938. /** additional data for the event */
  32939. additionalData?: any);
  32940. /**
  32941. * Helper function to auto-create an ActionEvent from a source mesh.
  32942. * @param source The source mesh that triggered the event
  32943. * @param evt The original (browser) event
  32944. * @param additionalData additional data for the event
  32945. * @returns the new ActionEvent
  32946. */
  32947. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  32948. /**
  32949. * Helper function to auto-create an ActionEvent from a source sprite
  32950. * @param source The source sprite that triggered the event
  32951. * @param scene Scene associated with the sprite
  32952. * @param evt The original (browser) event
  32953. * @param additionalData additional data for the event
  32954. * @returns the new ActionEvent
  32955. */
  32956. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  32957. /**
  32958. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  32959. * @param scene the scene where the event occurred
  32960. * @param evt The original (browser) event
  32961. * @returns the new ActionEvent
  32962. */
  32963. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  32964. /**
  32965. * Helper function to auto-create an ActionEvent from a primitive
  32966. * @param prim defines the target primitive
  32967. * @param pointerPos defines the pointer position
  32968. * @param evt The original (browser) event
  32969. * @param additionalData additional data for the event
  32970. * @returns the new ActionEvent
  32971. */
  32972. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  32973. }
  32974. }
  32975. declare module BABYLON {
  32976. /**
  32977. * Abstract class used to decouple action Manager from scene and meshes.
  32978. * Do not instantiate.
  32979. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  32980. */
  32981. export abstract class AbstractActionManager implements IDisposable {
  32982. /** Gets the list of active triggers */
  32983. static Triggers: {
  32984. [key: string]: number;
  32985. };
  32986. /** Gets the cursor to use when hovering items */
  32987. hoverCursor: string;
  32988. /** Gets the list of actions */
  32989. actions: IAction[];
  32990. /**
  32991. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  32992. */
  32993. isRecursive: boolean;
  32994. /**
  32995. * Releases all associated resources
  32996. */
  32997. abstract dispose(): void;
  32998. /**
  32999. * Does this action manager has pointer triggers
  33000. */
  33001. abstract get hasPointerTriggers(): boolean;
  33002. /**
  33003. * Does this action manager has pick triggers
  33004. */
  33005. abstract get hasPickTriggers(): boolean;
  33006. /**
  33007. * Process a specific trigger
  33008. * @param trigger defines the trigger to process
  33009. * @param evt defines the event details to be processed
  33010. */
  33011. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  33012. /**
  33013. * Does this action manager handles actions of any of the given triggers
  33014. * @param triggers defines the triggers to be tested
  33015. * @return a boolean indicating whether one (or more) of the triggers is handled
  33016. */
  33017. abstract hasSpecificTriggers(triggers: number[]): boolean;
  33018. /**
  33019. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  33020. * speed.
  33021. * @param triggerA defines the trigger to be tested
  33022. * @param triggerB defines the trigger to be tested
  33023. * @return a boolean indicating whether one (or more) of the triggers is handled
  33024. */
  33025. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  33026. /**
  33027. * Does this action manager handles actions of a given trigger
  33028. * @param trigger defines the trigger to be tested
  33029. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  33030. * @return whether the trigger is handled
  33031. */
  33032. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  33033. /**
  33034. * Serialize this manager to a JSON object
  33035. * @param name defines the property name to store this manager
  33036. * @returns a JSON representation of this manager
  33037. */
  33038. abstract serialize(name: string): any;
  33039. /**
  33040. * Registers an action to this action manager
  33041. * @param action defines the action to be registered
  33042. * @return the action amended (prepared) after registration
  33043. */
  33044. abstract registerAction(action: IAction): Nullable<IAction>;
  33045. /**
  33046. * Unregisters an action to this action manager
  33047. * @param action defines the action to be unregistered
  33048. * @return a boolean indicating whether the action has been unregistered
  33049. */
  33050. abstract unregisterAction(action: IAction): Boolean;
  33051. /**
  33052. * Does exist one action manager with at least one trigger
  33053. **/
  33054. static get HasTriggers(): boolean;
  33055. /**
  33056. * Does exist one action manager with at least one pick trigger
  33057. **/
  33058. static get HasPickTriggers(): boolean;
  33059. /**
  33060. * Does exist one action manager that handles actions of a given trigger
  33061. * @param trigger defines the trigger to be tested
  33062. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  33063. **/
  33064. static HasSpecificTrigger(trigger: number): boolean;
  33065. }
  33066. }
  33067. declare module BABYLON {
  33068. /**
  33069. * Defines how a node can be built from a string name.
  33070. */
  33071. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  33072. /**
  33073. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  33074. */
  33075. export class Node implements IBehaviorAware<Node> {
  33076. /** @hidden */
  33077. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  33078. private static _NodeConstructors;
  33079. /**
  33080. * Add a new node constructor
  33081. * @param type defines the type name of the node to construct
  33082. * @param constructorFunc defines the constructor function
  33083. */
  33084. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  33085. /**
  33086. * Returns a node constructor based on type name
  33087. * @param type defines the type name
  33088. * @param name defines the new node name
  33089. * @param scene defines the hosting scene
  33090. * @param options defines optional options to transmit to constructors
  33091. * @returns the new constructor or null
  33092. */
  33093. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  33094. /**
  33095. * Gets or sets the name of the node
  33096. */
  33097. name: string;
  33098. /**
  33099. * Gets or sets the id of the node
  33100. */
  33101. id: string;
  33102. /**
  33103. * Gets or sets the unique id of the node
  33104. */
  33105. uniqueId: number;
  33106. /**
  33107. * Gets or sets a string used to store user defined state for the node
  33108. */
  33109. state: string;
  33110. /**
  33111. * Gets or sets an object used to store user defined information for the node
  33112. */
  33113. metadata: any;
  33114. /**
  33115. * For internal use only. Please do not use.
  33116. */
  33117. reservedDataStore: any;
  33118. /**
  33119. * List of inspectable custom properties (used by the Inspector)
  33120. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  33121. */
  33122. inspectableCustomProperties: IInspectable[];
  33123. private _doNotSerialize;
  33124. /**
  33125. * Gets or sets a boolean used to define if the node must be serialized
  33126. */
  33127. get doNotSerialize(): boolean;
  33128. set doNotSerialize(value: boolean);
  33129. /** @hidden */
  33130. _isDisposed: boolean;
  33131. /**
  33132. * Gets a list of Animations associated with the node
  33133. */
  33134. animations: Animation[];
  33135. protected _ranges: {
  33136. [name: string]: Nullable<AnimationRange>;
  33137. };
  33138. /**
  33139. * Callback raised when the node is ready to be used
  33140. */
  33141. onReady: Nullable<(node: Node) => void>;
  33142. private _isEnabled;
  33143. private _isParentEnabled;
  33144. private _isReady;
  33145. /** @hidden */
  33146. _currentRenderId: number;
  33147. private _parentUpdateId;
  33148. /** @hidden */
  33149. _childUpdateId: number;
  33150. /** @hidden */
  33151. _waitingParentId: Nullable<string>;
  33152. /** @hidden */
  33153. _scene: Scene;
  33154. /** @hidden */
  33155. _cache: any;
  33156. private _parentNode;
  33157. private _children;
  33158. /** @hidden */
  33159. _worldMatrix: Matrix;
  33160. /** @hidden */
  33161. _worldMatrixDeterminant: number;
  33162. /** @hidden */
  33163. _worldMatrixDeterminantIsDirty: boolean;
  33164. /** @hidden */
  33165. private _sceneRootNodesIndex;
  33166. /**
  33167. * Gets a boolean indicating if the node has been disposed
  33168. * @returns true if the node was disposed
  33169. */
  33170. isDisposed(): boolean;
  33171. /**
  33172. * Gets or sets the parent of the node (without keeping the current position in the scene)
  33173. * @see https://doc.babylonjs.com/how_to/parenting
  33174. */
  33175. set parent(parent: Nullable<Node>);
  33176. get parent(): Nullable<Node>;
  33177. /** @hidden */
  33178. _addToSceneRootNodes(): void;
  33179. /** @hidden */
  33180. _removeFromSceneRootNodes(): void;
  33181. private _animationPropertiesOverride;
  33182. /**
  33183. * Gets or sets the animation properties override
  33184. */
  33185. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  33186. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  33187. /**
  33188. * Gets a string identifying the name of the class
  33189. * @returns "Node" string
  33190. */
  33191. getClassName(): string;
  33192. /** @hidden */
  33193. readonly _isNode: boolean;
  33194. /**
  33195. * An event triggered when the mesh is disposed
  33196. */
  33197. onDisposeObservable: Observable<Node>;
  33198. private _onDisposeObserver;
  33199. /**
  33200. * Sets a callback that will be raised when the node will be disposed
  33201. */
  33202. set onDispose(callback: () => void);
  33203. /**
  33204. * Creates a new Node
  33205. * @param name the name and id to be given to this node
  33206. * @param scene the scene this node will be added to
  33207. */
  33208. constructor(name: string, scene?: Nullable<Scene>);
  33209. /**
  33210. * Gets the scene of the node
  33211. * @returns a scene
  33212. */
  33213. getScene(): Scene;
  33214. /**
  33215. * Gets the engine of the node
  33216. * @returns a Engine
  33217. */
  33218. getEngine(): Engine;
  33219. private _behaviors;
  33220. /**
  33221. * Attach a behavior to the node
  33222. * @see https://doc.babylonjs.com/features/behaviour
  33223. * @param behavior defines the behavior to attach
  33224. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  33225. * @returns the current Node
  33226. */
  33227. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  33228. /**
  33229. * Remove an attached behavior
  33230. * @see https://doc.babylonjs.com/features/behaviour
  33231. * @param behavior defines the behavior to attach
  33232. * @returns the current Node
  33233. */
  33234. removeBehavior(behavior: Behavior<Node>): Node;
  33235. /**
  33236. * Gets the list of attached behaviors
  33237. * @see https://doc.babylonjs.com/features/behaviour
  33238. */
  33239. get behaviors(): Behavior<Node>[];
  33240. /**
  33241. * Gets an attached behavior by name
  33242. * @param name defines the name of the behavior to look for
  33243. * @see https://doc.babylonjs.com/features/behaviour
  33244. * @returns null if behavior was not found else the requested behavior
  33245. */
  33246. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  33247. /**
  33248. * Returns the latest update of the World matrix
  33249. * @returns a Matrix
  33250. */
  33251. getWorldMatrix(): Matrix;
  33252. /** @hidden */
  33253. _getWorldMatrixDeterminant(): number;
  33254. /**
  33255. * Returns directly the latest state of the mesh World matrix.
  33256. * A Matrix is returned.
  33257. */
  33258. get worldMatrixFromCache(): Matrix;
  33259. /** @hidden */
  33260. _initCache(): void;
  33261. /** @hidden */
  33262. updateCache(force?: boolean): void;
  33263. /** @hidden */
  33264. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33265. /** @hidden */
  33266. _updateCache(ignoreParentClass?: boolean): void;
  33267. /** @hidden */
  33268. _isSynchronized(): boolean;
  33269. /** @hidden */
  33270. _markSyncedWithParent(): void;
  33271. /** @hidden */
  33272. isSynchronizedWithParent(): boolean;
  33273. /** @hidden */
  33274. isSynchronized(): boolean;
  33275. /**
  33276. * Is this node ready to be used/rendered
  33277. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33278. * @return true if the node is ready
  33279. */
  33280. isReady(completeCheck?: boolean): boolean;
  33281. /**
  33282. * Is this node enabled?
  33283. * 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
  33284. * @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
  33285. * @return whether this node (and its parent) is enabled
  33286. */
  33287. isEnabled(checkAncestors?: boolean): boolean;
  33288. /** @hidden */
  33289. protected _syncParentEnabledState(): void;
  33290. /**
  33291. * Set the enabled state of this node
  33292. * @param value defines the new enabled state
  33293. */
  33294. setEnabled(value: boolean): void;
  33295. /**
  33296. * Is this node a descendant of the given node?
  33297. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  33298. * @param ancestor defines the parent node to inspect
  33299. * @returns a boolean indicating if this node is a descendant of the given node
  33300. */
  33301. isDescendantOf(ancestor: Node): boolean;
  33302. /** @hidden */
  33303. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  33304. /**
  33305. * Will return all nodes that have this node as ascendant
  33306. * @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
  33307. * @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
  33308. * @return all children nodes of all types
  33309. */
  33310. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  33311. /**
  33312. * Get all child-meshes of this node
  33313. * @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)
  33314. * @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
  33315. * @returns an array of AbstractMesh
  33316. */
  33317. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  33318. /**
  33319. * Get all direct children of this node
  33320. * @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
  33321. * @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)
  33322. * @returns an array of Node
  33323. */
  33324. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  33325. /** @hidden */
  33326. _setReady(state: boolean): void;
  33327. /**
  33328. * Get an animation by name
  33329. * @param name defines the name of the animation to look for
  33330. * @returns null if not found else the requested animation
  33331. */
  33332. getAnimationByName(name: string): Nullable<Animation>;
  33333. /**
  33334. * Creates an animation range for this node
  33335. * @param name defines the name of the range
  33336. * @param from defines the starting key
  33337. * @param to defines the end key
  33338. */
  33339. createAnimationRange(name: string, from: number, to: number): void;
  33340. /**
  33341. * Delete a specific animation range
  33342. * @param name defines the name of the range to delete
  33343. * @param deleteFrames defines if animation frames from the range must be deleted as well
  33344. */
  33345. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  33346. /**
  33347. * Get an animation range by name
  33348. * @param name defines the name of the animation range to look for
  33349. * @returns null if not found else the requested animation range
  33350. */
  33351. getAnimationRange(name: string): Nullable<AnimationRange>;
  33352. /**
  33353. * Gets the list of all animation ranges defined on this node
  33354. * @returns an array
  33355. */
  33356. getAnimationRanges(): Nullable<AnimationRange>[];
  33357. /**
  33358. * Will start the animation sequence
  33359. * @param name defines the range frames for animation sequence
  33360. * @param loop defines if the animation should loop (false by default)
  33361. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  33362. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  33363. * @returns the object created for this animation. If range does not exist, it will return null
  33364. */
  33365. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  33366. /**
  33367. * Serialize animation ranges into a JSON compatible object
  33368. * @returns serialization object
  33369. */
  33370. serializeAnimationRanges(): any;
  33371. /**
  33372. * Computes the world matrix of the node
  33373. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  33374. * @returns the world matrix
  33375. */
  33376. computeWorldMatrix(force?: boolean): Matrix;
  33377. /**
  33378. * Releases resources associated with this node.
  33379. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33380. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33381. */
  33382. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33383. /**
  33384. * Parse animation range data from a serialization object and store them into a given node
  33385. * @param node defines where to store the animation ranges
  33386. * @param parsedNode defines the serialization object to read data from
  33387. * @param scene defines the hosting scene
  33388. */
  33389. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  33390. /**
  33391. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  33392. * @param includeDescendants Include bounding info from descendants as well (true by default)
  33393. * @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
  33394. * @returns the new bounding vectors
  33395. */
  33396. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  33397. min: Vector3;
  33398. max: Vector3;
  33399. };
  33400. }
  33401. }
  33402. declare module BABYLON {
  33403. /**
  33404. * @hidden
  33405. */
  33406. export class _IAnimationState {
  33407. key: number;
  33408. repeatCount: number;
  33409. workValue?: any;
  33410. loopMode?: number;
  33411. offsetValue?: any;
  33412. highLimitValue?: any;
  33413. }
  33414. /**
  33415. * Class used to store any kind of animation
  33416. */
  33417. export class Animation {
  33418. /**Name of the animation */
  33419. name: string;
  33420. /**Property to animate */
  33421. targetProperty: string;
  33422. /**The frames per second of the animation */
  33423. framePerSecond: number;
  33424. /**The data type of the animation */
  33425. dataType: number;
  33426. /**The loop mode of the animation */
  33427. loopMode?: number | undefined;
  33428. /**Specifies if blending should be enabled */
  33429. enableBlending?: boolean | undefined;
  33430. /**
  33431. * Use matrix interpolation instead of using direct key value when animating matrices
  33432. */
  33433. static AllowMatricesInterpolation: boolean;
  33434. /**
  33435. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  33436. */
  33437. static AllowMatrixDecomposeForInterpolation: boolean;
  33438. /** Define the Url to load snippets */
  33439. static SnippetUrl: string;
  33440. /** Snippet ID if the animation was created from the snippet server */
  33441. snippetId: string;
  33442. /**
  33443. * Stores the key frames of the animation
  33444. */
  33445. private _keys;
  33446. /**
  33447. * Stores the easing function of the animation
  33448. */
  33449. private _easingFunction;
  33450. /**
  33451. * @hidden Internal use only
  33452. */
  33453. _runtimeAnimations: RuntimeAnimation[];
  33454. /**
  33455. * The set of event that will be linked to this animation
  33456. */
  33457. private _events;
  33458. /**
  33459. * Stores an array of target property paths
  33460. */
  33461. targetPropertyPath: string[];
  33462. /**
  33463. * Stores the blending speed of the animation
  33464. */
  33465. blendingSpeed: number;
  33466. /**
  33467. * Stores the animation ranges for the animation
  33468. */
  33469. private _ranges;
  33470. /**
  33471. * @hidden Internal use
  33472. */
  33473. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  33474. /**
  33475. * Sets up an animation
  33476. * @param property The property to animate
  33477. * @param animationType The animation type to apply
  33478. * @param framePerSecond The frames per second of the animation
  33479. * @param easingFunction The easing function used in the animation
  33480. * @returns The created animation
  33481. */
  33482. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  33483. /**
  33484. * Create and start an animation on a node
  33485. * @param name defines the name of the global animation that will be run on all nodes
  33486. * @param node defines the root node where the animation will take place
  33487. * @param targetProperty defines property to animate
  33488. * @param framePerSecond defines the number of frame per second yo use
  33489. * @param totalFrame defines the number of frames in total
  33490. * @param from defines the initial value
  33491. * @param to defines the final value
  33492. * @param loopMode defines which loop mode you want to use (off by default)
  33493. * @param easingFunction defines the easing function to use (linear by default)
  33494. * @param onAnimationEnd defines the callback to call when animation end
  33495. * @returns the animatable created for this animation
  33496. */
  33497. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33498. /**
  33499. * Create and start an animation on a node and its descendants
  33500. * @param name defines the name of the global animation that will be run on all nodes
  33501. * @param node defines the root node where the animation will take place
  33502. * @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
  33503. * @param targetProperty defines property to animate
  33504. * @param framePerSecond defines the number of frame per second to use
  33505. * @param totalFrame defines the number of frames in total
  33506. * @param from defines the initial value
  33507. * @param to defines the final value
  33508. * @param loopMode defines which loop mode you want to use (off by default)
  33509. * @param easingFunction defines the easing function to use (linear by default)
  33510. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  33511. * @returns the list of animatables created for all nodes
  33512. * @example https://www.babylonjs-playground.com/#MH0VLI
  33513. */
  33514. 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[]>;
  33515. /**
  33516. * Creates a new animation, merges it with the existing animations and starts it
  33517. * @param name Name of the animation
  33518. * @param node Node which contains the scene that begins the animations
  33519. * @param targetProperty Specifies which property to animate
  33520. * @param framePerSecond The frames per second of the animation
  33521. * @param totalFrame The total number of frames
  33522. * @param from The frame at the beginning of the animation
  33523. * @param to The frame at the end of the animation
  33524. * @param loopMode Specifies the loop mode of the animation
  33525. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  33526. * @param onAnimationEnd Callback to run once the animation is complete
  33527. * @returns Nullable animation
  33528. */
  33529. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33530. /**
  33531. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  33532. * @param sourceAnimation defines the Animation containing keyframes to convert
  33533. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  33534. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  33535. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  33536. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  33537. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  33538. */
  33539. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  33540. /**
  33541. * Transition property of an host to the target Value
  33542. * @param property The property to transition
  33543. * @param targetValue The target Value of the property
  33544. * @param host The object where the property to animate belongs
  33545. * @param scene Scene used to run the animation
  33546. * @param frameRate Framerate (in frame/s) to use
  33547. * @param transition The transition type we want to use
  33548. * @param duration The duration of the animation, in milliseconds
  33549. * @param onAnimationEnd Callback trigger at the end of the animation
  33550. * @returns Nullable animation
  33551. */
  33552. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  33553. /**
  33554. * Return the array of runtime animations currently using this animation
  33555. */
  33556. get runtimeAnimations(): RuntimeAnimation[];
  33557. /**
  33558. * Specifies if any of the runtime animations are currently running
  33559. */
  33560. get hasRunningRuntimeAnimations(): boolean;
  33561. /**
  33562. * Initializes the animation
  33563. * @param name Name of the animation
  33564. * @param targetProperty Property to animate
  33565. * @param framePerSecond The frames per second of the animation
  33566. * @param dataType The data type of the animation
  33567. * @param loopMode The loop mode of the animation
  33568. * @param enableBlending Specifies if blending should be enabled
  33569. */
  33570. constructor(
  33571. /**Name of the animation */
  33572. name: string,
  33573. /**Property to animate */
  33574. targetProperty: string,
  33575. /**The frames per second of the animation */
  33576. framePerSecond: number,
  33577. /**The data type of the animation */
  33578. dataType: number,
  33579. /**The loop mode of the animation */
  33580. loopMode?: number | undefined,
  33581. /**Specifies if blending should be enabled */
  33582. enableBlending?: boolean | undefined);
  33583. /**
  33584. * Converts the animation to a string
  33585. * @param fullDetails support for multiple levels of logging within scene loading
  33586. * @returns String form of the animation
  33587. */
  33588. toString(fullDetails?: boolean): string;
  33589. /**
  33590. * Add an event to this animation
  33591. * @param event Event to add
  33592. */
  33593. addEvent(event: AnimationEvent): void;
  33594. /**
  33595. * Remove all events found at the given frame
  33596. * @param frame The frame to remove events from
  33597. */
  33598. removeEvents(frame: number): void;
  33599. /**
  33600. * Retrieves all the events from the animation
  33601. * @returns Events from the animation
  33602. */
  33603. getEvents(): AnimationEvent[];
  33604. /**
  33605. * Creates an animation range
  33606. * @param name Name of the animation range
  33607. * @param from Starting frame of the animation range
  33608. * @param to Ending frame of the animation
  33609. */
  33610. createRange(name: string, from: number, to: number): void;
  33611. /**
  33612. * Deletes an animation range by name
  33613. * @param name Name of the animation range to delete
  33614. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  33615. */
  33616. deleteRange(name: string, deleteFrames?: boolean): void;
  33617. /**
  33618. * Gets the animation range by name, or null if not defined
  33619. * @param name Name of the animation range
  33620. * @returns Nullable animation range
  33621. */
  33622. getRange(name: string): Nullable<AnimationRange>;
  33623. /**
  33624. * Gets the key frames from the animation
  33625. * @returns The key frames of the animation
  33626. */
  33627. getKeys(): Array<IAnimationKey>;
  33628. /**
  33629. * Gets the highest frame rate of the animation
  33630. * @returns Highest frame rate of the animation
  33631. */
  33632. getHighestFrame(): number;
  33633. /**
  33634. * Gets the easing function of the animation
  33635. * @returns Easing function of the animation
  33636. */
  33637. getEasingFunction(): IEasingFunction;
  33638. /**
  33639. * Sets the easing function of the animation
  33640. * @param easingFunction A custom mathematical formula for animation
  33641. */
  33642. setEasingFunction(easingFunction: EasingFunction): void;
  33643. /**
  33644. * Interpolates a scalar linearly
  33645. * @param startValue Start value of the animation curve
  33646. * @param endValue End value of the animation curve
  33647. * @param gradient Scalar amount to interpolate
  33648. * @returns Interpolated scalar value
  33649. */
  33650. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  33651. /**
  33652. * Interpolates a scalar cubically
  33653. * @param startValue Start value of the animation curve
  33654. * @param outTangent End tangent of the animation
  33655. * @param endValue End value of the animation curve
  33656. * @param inTangent Start tangent of the animation curve
  33657. * @param gradient Scalar amount to interpolate
  33658. * @returns Interpolated scalar value
  33659. */
  33660. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  33661. /**
  33662. * Interpolates a quaternion using a spherical linear interpolation
  33663. * @param startValue Start value of the animation curve
  33664. * @param endValue End value of the animation curve
  33665. * @param gradient Scalar amount to interpolate
  33666. * @returns Interpolated quaternion value
  33667. */
  33668. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  33669. /**
  33670. * Interpolates a quaternion cubically
  33671. * @param startValue Start value of the animation curve
  33672. * @param outTangent End tangent of the animation curve
  33673. * @param endValue End value of the animation curve
  33674. * @param inTangent Start tangent of the animation curve
  33675. * @param gradient Scalar amount to interpolate
  33676. * @returns Interpolated quaternion value
  33677. */
  33678. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  33679. /**
  33680. * Interpolates a Vector3 linearl
  33681. * @param startValue Start value of the animation curve
  33682. * @param endValue End value of the animation curve
  33683. * @param gradient Scalar amount to interpolate
  33684. * @returns Interpolated scalar value
  33685. */
  33686. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  33687. /**
  33688. * Interpolates a Vector3 cubically
  33689. * @param startValue Start value of the animation curve
  33690. * @param outTangent End tangent of the animation
  33691. * @param endValue End value of the animation curve
  33692. * @param inTangent Start tangent of the animation curve
  33693. * @param gradient Scalar amount to interpolate
  33694. * @returns InterpolatedVector3 value
  33695. */
  33696. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  33697. /**
  33698. * Interpolates a Vector2 linearly
  33699. * @param startValue Start value of the animation curve
  33700. * @param endValue End value of the animation curve
  33701. * @param gradient Scalar amount to interpolate
  33702. * @returns Interpolated Vector2 value
  33703. */
  33704. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  33705. /**
  33706. * Interpolates a Vector2 cubically
  33707. * @param startValue Start value of the animation curve
  33708. * @param outTangent End tangent of the animation
  33709. * @param endValue End value of the animation curve
  33710. * @param inTangent Start tangent of the animation curve
  33711. * @param gradient Scalar amount to interpolate
  33712. * @returns Interpolated Vector2 value
  33713. */
  33714. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  33715. /**
  33716. * Interpolates a size linearly
  33717. * @param startValue Start value of the animation curve
  33718. * @param endValue End value of the animation curve
  33719. * @param gradient Scalar amount to interpolate
  33720. * @returns Interpolated Size value
  33721. */
  33722. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  33723. /**
  33724. * Interpolates a Color3 linearly
  33725. * @param startValue Start value of the animation curve
  33726. * @param endValue End value of the animation curve
  33727. * @param gradient Scalar amount to interpolate
  33728. * @returns Interpolated Color3 value
  33729. */
  33730. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  33731. /**
  33732. * Interpolates a Color4 linearly
  33733. * @param startValue Start value of the animation curve
  33734. * @param endValue End value of the animation curve
  33735. * @param gradient Scalar amount to interpolate
  33736. * @returns Interpolated Color3 value
  33737. */
  33738. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  33739. /**
  33740. * @hidden Internal use only
  33741. */
  33742. _getKeyValue(value: any): any;
  33743. /**
  33744. * @hidden Internal use only
  33745. */
  33746. _interpolate(currentFrame: number, state: _IAnimationState): any;
  33747. /**
  33748. * Defines the function to use to interpolate matrices
  33749. * @param startValue defines the start matrix
  33750. * @param endValue defines the end matrix
  33751. * @param gradient defines the gradient between both matrices
  33752. * @param result defines an optional target matrix where to store the interpolation
  33753. * @returns the interpolated matrix
  33754. */
  33755. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  33756. /**
  33757. * Makes a copy of the animation
  33758. * @returns Cloned animation
  33759. */
  33760. clone(): Animation;
  33761. /**
  33762. * Sets the key frames of the animation
  33763. * @param values The animation key frames to set
  33764. */
  33765. setKeys(values: Array<IAnimationKey>): void;
  33766. /**
  33767. * Serializes the animation to an object
  33768. * @returns Serialized object
  33769. */
  33770. serialize(): any;
  33771. /**
  33772. * Float animation type
  33773. */
  33774. static readonly ANIMATIONTYPE_FLOAT: number;
  33775. /**
  33776. * Vector3 animation type
  33777. */
  33778. static readonly ANIMATIONTYPE_VECTOR3: number;
  33779. /**
  33780. * Quaternion animation type
  33781. */
  33782. static readonly ANIMATIONTYPE_QUATERNION: number;
  33783. /**
  33784. * Matrix animation type
  33785. */
  33786. static readonly ANIMATIONTYPE_MATRIX: number;
  33787. /**
  33788. * Color3 animation type
  33789. */
  33790. static readonly ANIMATIONTYPE_COLOR3: number;
  33791. /**
  33792. * Color3 animation type
  33793. */
  33794. static readonly ANIMATIONTYPE_COLOR4: number;
  33795. /**
  33796. * Vector2 animation type
  33797. */
  33798. static readonly ANIMATIONTYPE_VECTOR2: number;
  33799. /**
  33800. * Size animation type
  33801. */
  33802. static readonly ANIMATIONTYPE_SIZE: number;
  33803. /**
  33804. * Relative Loop Mode
  33805. */
  33806. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  33807. /**
  33808. * Cycle Loop Mode
  33809. */
  33810. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  33811. /**
  33812. * Constant Loop Mode
  33813. */
  33814. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  33815. /** @hidden */
  33816. static _UniversalLerp(left: any, right: any, amount: number): any;
  33817. /**
  33818. * Parses an animation object and creates an animation
  33819. * @param parsedAnimation Parsed animation object
  33820. * @returns Animation object
  33821. */
  33822. static Parse(parsedAnimation: any): Animation;
  33823. /**
  33824. * Appends the serialized animations from the source animations
  33825. * @param source Source containing the animations
  33826. * @param destination Target to store the animations
  33827. */
  33828. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33829. /**
  33830. * Creates a new animation or an array of animations from a snippet saved in a remote file
  33831. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  33832. * @param url defines the url to load from
  33833. * @returns a promise that will resolve to the new animation or an array of animations
  33834. */
  33835. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  33836. /**
  33837. * Creates an animation or an array of animations from a snippet saved by the Inspector
  33838. * @param snippetId defines the snippet to load
  33839. * @returns a promise that will resolve to the new animation or a new array of animations
  33840. */
  33841. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  33842. }
  33843. }
  33844. declare module BABYLON {
  33845. /**
  33846. * Interface containing an array of animations
  33847. */
  33848. export interface IAnimatable {
  33849. /**
  33850. * Array of animations
  33851. */
  33852. animations: Nullable<Array<Animation>>;
  33853. }
  33854. }
  33855. declare module BABYLON {
  33856. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  33857. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33858. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33859. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33860. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33861. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33862. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33863. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33864. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33865. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33866. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33867. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33868. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33869. /**
  33870. * Decorator used to define property that can be serialized as reference to a camera
  33871. * @param sourceName defines the name of the property to decorate
  33872. */
  33873. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33874. /**
  33875. * Class used to help serialization objects
  33876. */
  33877. export class SerializationHelper {
  33878. /** @hidden */
  33879. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  33880. /** @hidden */
  33881. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  33882. /** @hidden */
  33883. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  33884. /** @hidden */
  33885. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  33886. /**
  33887. * Appends the serialized animations from the source animations
  33888. * @param source Source containing the animations
  33889. * @param destination Target to store the animations
  33890. */
  33891. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33892. /**
  33893. * Static function used to serialized a specific entity
  33894. * @param entity defines the entity to serialize
  33895. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  33896. * @returns a JSON compatible object representing the serialization of the entity
  33897. */
  33898. static Serialize<T>(entity: T, serializationObject?: any): any;
  33899. /**
  33900. * Creates a new entity from a serialization data object
  33901. * @param creationFunction defines a function used to instanciated the new entity
  33902. * @param source defines the source serialization data
  33903. * @param scene defines the hosting scene
  33904. * @param rootUrl defines the root url for resources
  33905. * @returns a new entity
  33906. */
  33907. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  33908. /**
  33909. * Clones an object
  33910. * @param creationFunction defines the function used to instanciate the new object
  33911. * @param source defines the source object
  33912. * @returns the cloned object
  33913. */
  33914. static Clone<T>(creationFunction: () => T, source: T): T;
  33915. /**
  33916. * Instanciates a new object based on a source one (some data will be shared between both object)
  33917. * @param creationFunction defines the function used to instanciate the new object
  33918. * @param source defines the source object
  33919. * @returns the new object
  33920. */
  33921. static Instanciate<T>(creationFunction: () => T, source: T): T;
  33922. }
  33923. }
  33924. declare module BABYLON {
  33925. /**
  33926. * Base class of all the textures in babylon.
  33927. * It groups all the common properties the materials, post process, lights... might need
  33928. * in order to make a correct use of the texture.
  33929. */
  33930. export class BaseTexture implements IAnimatable {
  33931. /**
  33932. * Default anisotropic filtering level for the application.
  33933. * It is set to 4 as a good tradeoff between perf and quality.
  33934. */
  33935. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  33936. /**
  33937. * Gets or sets the unique id of the texture
  33938. */
  33939. uniqueId: number;
  33940. /**
  33941. * Define the name of the texture.
  33942. */
  33943. name: string;
  33944. /**
  33945. * Gets or sets an object used to store user defined information.
  33946. */
  33947. metadata: any;
  33948. /**
  33949. * For internal use only. Please do not use.
  33950. */
  33951. reservedDataStore: any;
  33952. private _hasAlpha;
  33953. /**
  33954. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  33955. */
  33956. set hasAlpha(value: boolean);
  33957. get hasAlpha(): boolean;
  33958. /**
  33959. * Defines if the alpha value should be determined via the rgb values.
  33960. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  33961. */
  33962. getAlphaFromRGB: boolean;
  33963. /**
  33964. * Intensity or strength of the texture.
  33965. * It is commonly used by materials to fine tune the intensity of the texture
  33966. */
  33967. level: number;
  33968. /**
  33969. * Define the UV chanel to use starting from 0 and defaulting to 0.
  33970. * This is part of the texture as textures usually maps to one uv set.
  33971. */
  33972. coordinatesIndex: number;
  33973. protected _coordinatesMode: number;
  33974. /**
  33975. * How a texture is mapped.
  33976. *
  33977. * | Value | Type | Description |
  33978. * | ----- | ----------------------------------- | ----------- |
  33979. * | 0 | EXPLICIT_MODE | |
  33980. * | 1 | SPHERICAL_MODE | |
  33981. * | 2 | PLANAR_MODE | |
  33982. * | 3 | CUBIC_MODE | |
  33983. * | 4 | PROJECTION_MODE | |
  33984. * | 5 | SKYBOX_MODE | |
  33985. * | 6 | INVCUBIC_MODE | |
  33986. * | 7 | EQUIRECTANGULAR_MODE | |
  33987. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  33988. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  33989. */
  33990. set coordinatesMode(value: number);
  33991. get coordinatesMode(): number;
  33992. private _wrapU;
  33993. /**
  33994. * | Value | Type | Description |
  33995. * | ----- | ------------------ | ----------- |
  33996. * | 0 | CLAMP_ADDRESSMODE | |
  33997. * | 1 | WRAP_ADDRESSMODE | |
  33998. * | 2 | MIRROR_ADDRESSMODE | |
  33999. */
  34000. get wrapU(): number;
  34001. set wrapU(value: number);
  34002. private _wrapV;
  34003. /**
  34004. * | Value | Type | Description |
  34005. * | ----- | ------------------ | ----------- |
  34006. * | 0 | CLAMP_ADDRESSMODE | |
  34007. * | 1 | WRAP_ADDRESSMODE | |
  34008. * | 2 | MIRROR_ADDRESSMODE | |
  34009. */
  34010. get wrapV(): number;
  34011. set wrapV(value: number);
  34012. /**
  34013. * | Value | Type | Description |
  34014. * | ----- | ------------------ | ----------- |
  34015. * | 0 | CLAMP_ADDRESSMODE | |
  34016. * | 1 | WRAP_ADDRESSMODE | |
  34017. * | 2 | MIRROR_ADDRESSMODE | |
  34018. */
  34019. wrapR: number;
  34020. /**
  34021. * With compliant hardware and browser (supporting anisotropic filtering)
  34022. * this defines the level of anisotropic filtering in the texture.
  34023. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  34024. */
  34025. anisotropicFilteringLevel: number;
  34026. /**
  34027. * Define if the texture is a cube texture or if false a 2d texture.
  34028. */
  34029. get isCube(): boolean;
  34030. set isCube(value: boolean);
  34031. /**
  34032. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  34033. */
  34034. get is3D(): boolean;
  34035. set is3D(value: boolean);
  34036. /**
  34037. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  34038. */
  34039. get is2DArray(): boolean;
  34040. set is2DArray(value: boolean);
  34041. private _gammaSpace;
  34042. /**
  34043. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  34044. * HDR texture are usually stored in linear space.
  34045. * This only impacts the PBR and Background materials
  34046. */
  34047. get gammaSpace(): boolean;
  34048. set gammaSpace(gamma: boolean);
  34049. /**
  34050. * Gets or sets whether or not the texture contains RGBD data.
  34051. */
  34052. get isRGBD(): boolean;
  34053. set isRGBD(value: boolean);
  34054. /**
  34055. * Is Z inverted in the texture (useful in a cube texture).
  34056. */
  34057. invertZ: boolean;
  34058. /**
  34059. * Are mip maps generated for this texture or not.
  34060. */
  34061. get noMipmap(): boolean;
  34062. /**
  34063. * @hidden
  34064. */
  34065. lodLevelInAlpha: boolean;
  34066. /**
  34067. * With prefiltered texture, defined the offset used during the prefiltering steps.
  34068. */
  34069. get lodGenerationOffset(): number;
  34070. set lodGenerationOffset(value: number);
  34071. /**
  34072. * With prefiltered texture, defined the scale used during the prefiltering steps.
  34073. */
  34074. get lodGenerationScale(): number;
  34075. set lodGenerationScale(value: number);
  34076. /**
  34077. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  34078. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  34079. * average roughness values.
  34080. */
  34081. get linearSpecularLOD(): boolean;
  34082. set linearSpecularLOD(value: boolean);
  34083. /**
  34084. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  34085. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  34086. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  34087. */
  34088. get irradianceTexture(): Nullable<BaseTexture>;
  34089. set irradianceTexture(value: Nullable<BaseTexture>);
  34090. /**
  34091. * Define if the texture is a render target.
  34092. */
  34093. isRenderTarget: boolean;
  34094. /**
  34095. * Define the unique id of the texture in the scene.
  34096. */
  34097. get uid(): string;
  34098. /** @hidden */
  34099. _prefiltered: boolean;
  34100. /**
  34101. * Return a string representation of the texture.
  34102. * @returns the texture as a string
  34103. */
  34104. toString(): string;
  34105. /**
  34106. * Get the class name of the texture.
  34107. * @returns "BaseTexture"
  34108. */
  34109. getClassName(): string;
  34110. /**
  34111. * Define the list of animation attached to the texture.
  34112. */
  34113. animations: Animation[];
  34114. /**
  34115. * An event triggered when the texture is disposed.
  34116. */
  34117. onDisposeObservable: Observable<BaseTexture>;
  34118. private _onDisposeObserver;
  34119. /**
  34120. * Callback triggered when the texture has been disposed.
  34121. * Kept for back compatibility, you can use the onDisposeObservable instead.
  34122. */
  34123. set onDispose(callback: () => void);
  34124. /**
  34125. * Define the current state of the loading sequence when in delayed load mode.
  34126. */
  34127. delayLoadState: number;
  34128. protected _scene: Nullable<Scene>;
  34129. protected _engine: Nullable<ThinEngine>;
  34130. /** @hidden */
  34131. _texture: Nullable<InternalTexture>;
  34132. private _uid;
  34133. /**
  34134. * Define if the texture is preventinga material to render or not.
  34135. * If not and the texture is not ready, the engine will use a default black texture instead.
  34136. */
  34137. get isBlocking(): boolean;
  34138. /**
  34139. * Instantiates a new BaseTexture.
  34140. * Base class of all the textures in babylon.
  34141. * It groups all the common properties the materials, post process, lights... might need
  34142. * in order to make a correct use of the texture.
  34143. * @param sceneOrEngine Define the scene or engine the texture blongs to
  34144. */
  34145. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  34146. /**
  34147. * Get the scene the texture belongs to.
  34148. * @returns the scene or null if undefined
  34149. */
  34150. getScene(): Nullable<Scene>;
  34151. /** @hidden */
  34152. protected _getEngine(): Nullable<ThinEngine>;
  34153. /**
  34154. * Get the texture transform matrix used to offset tile the texture for istance.
  34155. * @returns the transformation matrix
  34156. */
  34157. getTextureMatrix(): Matrix;
  34158. /**
  34159. * Get the texture reflection matrix used to rotate/transform the reflection.
  34160. * @returns the reflection matrix
  34161. */
  34162. getReflectionTextureMatrix(): Matrix;
  34163. /**
  34164. * Get the underlying lower level texture from Babylon.
  34165. * @returns the insternal texture
  34166. */
  34167. getInternalTexture(): Nullable<InternalTexture>;
  34168. /**
  34169. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  34170. * @returns true if ready or not blocking
  34171. */
  34172. isReadyOrNotBlocking(): boolean;
  34173. /**
  34174. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  34175. * @returns true if fully ready
  34176. */
  34177. isReady(): boolean;
  34178. private _cachedSize;
  34179. /**
  34180. * Get the size of the texture.
  34181. * @returns the texture size.
  34182. */
  34183. getSize(): ISize;
  34184. /**
  34185. * Get the base size of the texture.
  34186. * It can be different from the size if the texture has been resized for POT for instance
  34187. * @returns the base size
  34188. */
  34189. getBaseSize(): ISize;
  34190. /**
  34191. * Update the sampling mode of the texture.
  34192. * Default is Trilinear mode.
  34193. *
  34194. * | Value | Type | Description |
  34195. * | ----- | ------------------ | ----------- |
  34196. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  34197. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  34198. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  34199. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  34200. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  34201. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  34202. * | 7 | NEAREST_LINEAR | |
  34203. * | 8 | NEAREST_NEAREST | |
  34204. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  34205. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  34206. * | 11 | LINEAR_LINEAR | |
  34207. * | 12 | LINEAR_NEAREST | |
  34208. *
  34209. * > _mag_: magnification filter (close to the viewer)
  34210. * > _min_: minification filter (far from the viewer)
  34211. * > _mip_: filter used between mip map levels
  34212. *@param samplingMode Define the new sampling mode of the texture
  34213. */
  34214. updateSamplingMode(samplingMode: number): void;
  34215. /**
  34216. * Scales the texture if is `canRescale()`
  34217. * @param ratio the resize factor we want to use to rescale
  34218. */
  34219. scale(ratio: number): void;
  34220. /**
  34221. * Get if the texture can rescale.
  34222. */
  34223. get canRescale(): boolean;
  34224. /** @hidden */
  34225. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  34226. /** @hidden */
  34227. _rebuild(): void;
  34228. /**
  34229. * Triggers the load sequence in delayed load mode.
  34230. */
  34231. delayLoad(): void;
  34232. /**
  34233. * Clones the texture.
  34234. * @returns the cloned texture
  34235. */
  34236. clone(): Nullable<BaseTexture>;
  34237. /**
  34238. * Get the texture underlying type (INT, FLOAT...)
  34239. */
  34240. get textureType(): number;
  34241. /**
  34242. * Get the texture underlying format (RGB, RGBA...)
  34243. */
  34244. get textureFormat(): number;
  34245. /**
  34246. * Indicates that textures need to be re-calculated for all materials
  34247. */
  34248. protected _markAllSubMeshesAsTexturesDirty(): void;
  34249. /**
  34250. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  34251. * This will returns an RGBA array buffer containing either in values (0-255) or
  34252. * float values (0-1) depending of the underlying buffer type.
  34253. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  34254. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  34255. * @param buffer defines a user defined buffer to fill with data (can be null)
  34256. * @returns The Array buffer containing the pixels data.
  34257. */
  34258. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  34259. /**
  34260. * Release and destroy the underlying lower level texture aka internalTexture.
  34261. */
  34262. releaseInternalTexture(): void;
  34263. /** @hidden */
  34264. get _lodTextureHigh(): Nullable<BaseTexture>;
  34265. /** @hidden */
  34266. get _lodTextureMid(): Nullable<BaseTexture>;
  34267. /** @hidden */
  34268. get _lodTextureLow(): Nullable<BaseTexture>;
  34269. /**
  34270. * Dispose the texture and release its associated resources.
  34271. */
  34272. dispose(): void;
  34273. /**
  34274. * Serialize the texture into a JSON representation that can be parsed later on.
  34275. * @returns the JSON representation of the texture
  34276. */
  34277. serialize(): any;
  34278. /**
  34279. * Helper function to be called back once a list of texture contains only ready textures.
  34280. * @param textures Define the list of textures to wait for
  34281. * @param callback Define the callback triggered once the entire list will be ready
  34282. */
  34283. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  34284. private static _isScene;
  34285. }
  34286. }
  34287. declare module BABYLON {
  34288. /**
  34289. * Options to be used when creating an effect.
  34290. */
  34291. export interface IEffectCreationOptions {
  34292. /**
  34293. * Atrributes that will be used in the shader.
  34294. */
  34295. attributes: string[];
  34296. /**
  34297. * Uniform varible names that will be set in the shader.
  34298. */
  34299. uniformsNames: string[];
  34300. /**
  34301. * Uniform buffer variable names that will be set in the shader.
  34302. */
  34303. uniformBuffersNames: string[];
  34304. /**
  34305. * Sampler texture variable names that will be set in the shader.
  34306. */
  34307. samplers: string[];
  34308. /**
  34309. * Define statements that will be set in the shader.
  34310. */
  34311. defines: any;
  34312. /**
  34313. * Possible fallbacks for this effect to improve performance when needed.
  34314. */
  34315. fallbacks: Nullable<IEffectFallbacks>;
  34316. /**
  34317. * Callback that will be called when the shader is compiled.
  34318. */
  34319. onCompiled: Nullable<(effect: Effect) => void>;
  34320. /**
  34321. * Callback that will be called if an error occurs during shader compilation.
  34322. */
  34323. onError: Nullable<(effect: Effect, errors: string) => void>;
  34324. /**
  34325. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34326. */
  34327. indexParameters?: any;
  34328. /**
  34329. * Max number of lights that can be used in the shader.
  34330. */
  34331. maxSimultaneousLights?: number;
  34332. /**
  34333. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  34334. */
  34335. transformFeedbackVaryings?: Nullable<string[]>;
  34336. /**
  34337. * 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
  34338. */
  34339. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  34340. /**
  34341. * Is this effect rendering to several color attachments ?
  34342. */
  34343. multiTarget?: boolean;
  34344. }
  34345. /**
  34346. * Effect containing vertex and fragment shader that can be executed on an object.
  34347. */
  34348. export class Effect implements IDisposable {
  34349. /**
  34350. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34351. */
  34352. static ShadersRepository: string;
  34353. /**
  34354. * Enable logging of the shader code when a compilation error occurs
  34355. */
  34356. static LogShaderCodeOnCompilationError: boolean;
  34357. /**
  34358. * Name of the effect.
  34359. */
  34360. name: any;
  34361. /**
  34362. * String container all the define statements that should be set on the shader.
  34363. */
  34364. defines: string;
  34365. /**
  34366. * Callback that will be called when the shader is compiled.
  34367. */
  34368. onCompiled: Nullable<(effect: Effect) => void>;
  34369. /**
  34370. * Callback that will be called if an error occurs during shader compilation.
  34371. */
  34372. onError: Nullable<(effect: Effect, errors: string) => void>;
  34373. /**
  34374. * Callback that will be called when effect is bound.
  34375. */
  34376. onBind: Nullable<(effect: Effect) => void>;
  34377. /**
  34378. * Unique ID of the effect.
  34379. */
  34380. uniqueId: number;
  34381. /**
  34382. * Observable that will be called when the shader is compiled.
  34383. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  34384. */
  34385. onCompileObservable: Observable<Effect>;
  34386. /**
  34387. * Observable that will be called if an error occurs during shader compilation.
  34388. */
  34389. onErrorObservable: Observable<Effect>;
  34390. /** @hidden */
  34391. _onBindObservable: Nullable<Observable<Effect>>;
  34392. /**
  34393. * @hidden
  34394. * Specifies if the effect was previously ready
  34395. */
  34396. _wasPreviouslyReady: boolean;
  34397. /**
  34398. * Observable that will be called when effect is bound.
  34399. */
  34400. get onBindObservable(): Observable<Effect>;
  34401. /** @hidden */
  34402. _bonesComputationForcedToCPU: boolean;
  34403. /** @hidden */
  34404. _multiTarget: boolean;
  34405. private static _uniqueIdSeed;
  34406. private _engine;
  34407. private _uniformBuffersNames;
  34408. private _uniformBuffersNamesList;
  34409. private _uniformsNames;
  34410. private _samplerList;
  34411. private _samplers;
  34412. private _isReady;
  34413. private _compilationError;
  34414. private _allFallbacksProcessed;
  34415. private _attributesNames;
  34416. private _attributes;
  34417. private _attributeLocationByName;
  34418. private _uniforms;
  34419. /**
  34420. * Key for the effect.
  34421. * @hidden
  34422. */
  34423. _key: string;
  34424. private _indexParameters;
  34425. private _fallbacks;
  34426. private _vertexSourceCode;
  34427. private _fragmentSourceCode;
  34428. private _vertexSourceCodeOverride;
  34429. private _fragmentSourceCodeOverride;
  34430. private _transformFeedbackVaryings;
  34431. /**
  34432. * Compiled shader to webGL program.
  34433. * @hidden
  34434. */
  34435. _pipelineContext: Nullable<IPipelineContext>;
  34436. private _valueCache;
  34437. private static _baseCache;
  34438. /**
  34439. * Instantiates an effect.
  34440. * An effect can be used to create/manage/execute vertex and fragment shaders.
  34441. * @param baseName Name of the effect.
  34442. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  34443. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  34444. * @param samplers List of sampler variables that will be passed to the shader.
  34445. * @param engine Engine to be used to render the effect
  34446. * @param defines Define statements to be added to the shader.
  34447. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  34448. * @param onCompiled Callback that will be called when the shader is compiled.
  34449. * @param onError Callback that will be called if an error occurs during shader compilation.
  34450. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34451. */
  34452. 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);
  34453. private _useFinalCode;
  34454. /**
  34455. * Unique key for this effect
  34456. */
  34457. get key(): string;
  34458. /**
  34459. * If the effect has been compiled and prepared.
  34460. * @returns if the effect is compiled and prepared.
  34461. */
  34462. isReady(): boolean;
  34463. private _isReadyInternal;
  34464. /**
  34465. * The engine the effect was initialized with.
  34466. * @returns the engine.
  34467. */
  34468. getEngine(): Engine;
  34469. /**
  34470. * The pipeline context for this effect
  34471. * @returns the associated pipeline context
  34472. */
  34473. getPipelineContext(): Nullable<IPipelineContext>;
  34474. /**
  34475. * The set of names of attribute variables for the shader.
  34476. * @returns An array of attribute names.
  34477. */
  34478. getAttributesNames(): string[];
  34479. /**
  34480. * Returns the attribute at the given index.
  34481. * @param index The index of the attribute.
  34482. * @returns The location of the attribute.
  34483. */
  34484. getAttributeLocation(index: number): number;
  34485. /**
  34486. * Returns the attribute based on the name of the variable.
  34487. * @param name of the attribute to look up.
  34488. * @returns the attribute location.
  34489. */
  34490. getAttributeLocationByName(name: string): number;
  34491. /**
  34492. * The number of attributes.
  34493. * @returns the numnber of attributes.
  34494. */
  34495. getAttributesCount(): number;
  34496. /**
  34497. * Gets the index of a uniform variable.
  34498. * @param uniformName of the uniform to look up.
  34499. * @returns the index.
  34500. */
  34501. getUniformIndex(uniformName: string): number;
  34502. /**
  34503. * Returns the attribute based on the name of the variable.
  34504. * @param uniformName of the uniform to look up.
  34505. * @returns the location of the uniform.
  34506. */
  34507. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  34508. /**
  34509. * Returns an array of sampler variable names
  34510. * @returns The array of sampler variable names.
  34511. */
  34512. getSamplers(): string[];
  34513. /**
  34514. * Returns an array of uniform variable names
  34515. * @returns The array of uniform variable names.
  34516. */
  34517. getUniformNames(): string[];
  34518. /**
  34519. * Returns an array of uniform buffer variable names
  34520. * @returns The array of uniform buffer variable names.
  34521. */
  34522. getUniformBuffersNames(): string[];
  34523. /**
  34524. * Returns the index parameters used to create the effect
  34525. * @returns The index parameters object
  34526. */
  34527. getIndexParameters(): any;
  34528. /**
  34529. * The error from the last compilation.
  34530. * @returns the error string.
  34531. */
  34532. getCompilationError(): string;
  34533. /**
  34534. * Gets a boolean indicating that all fallbacks were used during compilation
  34535. * @returns true if all fallbacks were used
  34536. */
  34537. allFallbacksProcessed(): boolean;
  34538. /**
  34539. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  34540. * @param func The callback to be used.
  34541. */
  34542. executeWhenCompiled(func: (effect: Effect) => void): void;
  34543. private _checkIsReady;
  34544. private _loadShader;
  34545. /**
  34546. * Gets the vertex shader source code of this effect
  34547. */
  34548. get vertexSourceCode(): string;
  34549. /**
  34550. * Gets the fragment shader source code of this effect
  34551. */
  34552. get fragmentSourceCode(): string;
  34553. /**
  34554. * Recompiles the webGL program
  34555. * @param vertexSourceCode The source code for the vertex shader.
  34556. * @param fragmentSourceCode The source code for the fragment shader.
  34557. * @param onCompiled Callback called when completed.
  34558. * @param onError Callback called on error.
  34559. * @hidden
  34560. */
  34561. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  34562. /**
  34563. * Prepares the effect
  34564. * @hidden
  34565. */
  34566. _prepareEffect(): void;
  34567. private _getShaderCodeAndErrorLine;
  34568. private _processCompilationErrors;
  34569. /**
  34570. * Checks if the effect is supported. (Must be called after compilation)
  34571. */
  34572. get isSupported(): boolean;
  34573. /**
  34574. * Binds a texture to the engine to be used as output of the shader.
  34575. * @param channel Name of the output variable.
  34576. * @param texture Texture to bind.
  34577. * @hidden
  34578. */
  34579. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  34580. /**
  34581. * Sets a texture on the engine to be used in the shader.
  34582. * @param channel Name of the sampler variable.
  34583. * @param texture Texture to set.
  34584. */
  34585. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  34586. /**
  34587. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  34588. * @param channel Name of the sampler variable.
  34589. * @param texture Texture to set.
  34590. */
  34591. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  34592. /**
  34593. * Sets an array of textures on the engine to be used in the shader.
  34594. * @param channel Name of the variable.
  34595. * @param textures Textures to set.
  34596. */
  34597. setTextureArray(channel: string, textures: BaseTexture[]): void;
  34598. /**
  34599. * 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)
  34600. * @param channel Name of the sampler variable.
  34601. * @param postProcess Post process to get the input texture from.
  34602. */
  34603. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  34604. /**
  34605. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  34606. * 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)
  34607. * @param channel Name of the sampler variable.
  34608. * @param postProcess Post process to get the output texture from.
  34609. */
  34610. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  34611. /** @hidden */
  34612. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  34613. /** @hidden */
  34614. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  34615. /** @hidden */
  34616. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  34617. /** @hidden */
  34618. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  34619. /**
  34620. * Binds a buffer to a uniform.
  34621. * @param buffer Buffer to bind.
  34622. * @param name Name of the uniform variable to bind to.
  34623. */
  34624. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  34625. /**
  34626. * Binds block to a uniform.
  34627. * @param blockName Name of the block to bind.
  34628. * @param index Index to bind.
  34629. */
  34630. bindUniformBlock(blockName: string, index: number): void;
  34631. /**
  34632. * Sets an interger value on a uniform variable.
  34633. * @param uniformName Name of the variable.
  34634. * @param value Value to be set.
  34635. * @returns this effect.
  34636. */
  34637. setInt(uniformName: string, value: number): Effect;
  34638. /**
  34639. * Sets an int array on a uniform variable.
  34640. * @param uniformName Name of the variable.
  34641. * @param array array to be set.
  34642. * @returns this effect.
  34643. */
  34644. setIntArray(uniformName: string, array: Int32Array): Effect;
  34645. /**
  34646. * 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)
  34647. * @param uniformName Name of the variable.
  34648. * @param array array to be set.
  34649. * @returns this effect.
  34650. */
  34651. setIntArray2(uniformName: string, array: Int32Array): Effect;
  34652. /**
  34653. * 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)
  34654. * @param uniformName Name of the variable.
  34655. * @param array array to be set.
  34656. * @returns this effect.
  34657. */
  34658. setIntArray3(uniformName: string, array: Int32Array): Effect;
  34659. /**
  34660. * 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)
  34661. * @param uniformName Name of the variable.
  34662. * @param array array to be set.
  34663. * @returns this effect.
  34664. */
  34665. setIntArray4(uniformName: string, array: Int32Array): Effect;
  34666. /**
  34667. * Sets an float array on a uniform variable.
  34668. * @param uniformName Name of the variable.
  34669. * @param array array to be set.
  34670. * @returns this effect.
  34671. */
  34672. setFloatArray(uniformName: string, array: Float32Array): Effect;
  34673. /**
  34674. * 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)
  34675. * @param uniformName Name of the variable.
  34676. * @param array array to be set.
  34677. * @returns this effect.
  34678. */
  34679. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  34680. /**
  34681. * 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)
  34682. * @param uniformName Name of the variable.
  34683. * @param array array to be set.
  34684. * @returns this effect.
  34685. */
  34686. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  34687. /**
  34688. * 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)
  34689. * @param uniformName Name of the variable.
  34690. * @param array array to be set.
  34691. * @returns this effect.
  34692. */
  34693. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  34694. /**
  34695. * Sets an array on a uniform variable.
  34696. * @param uniformName Name of the variable.
  34697. * @param array array to be set.
  34698. * @returns this effect.
  34699. */
  34700. setArray(uniformName: string, array: number[]): Effect;
  34701. /**
  34702. * 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)
  34703. * @param uniformName Name of the variable.
  34704. * @param array array to be set.
  34705. * @returns this effect.
  34706. */
  34707. setArray2(uniformName: string, array: number[]): Effect;
  34708. /**
  34709. * 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)
  34710. * @param uniformName Name of the variable.
  34711. * @param array array to be set.
  34712. * @returns this effect.
  34713. */
  34714. setArray3(uniformName: string, array: number[]): Effect;
  34715. /**
  34716. * 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)
  34717. * @param uniformName Name of the variable.
  34718. * @param array array to be set.
  34719. * @returns this effect.
  34720. */
  34721. setArray4(uniformName: string, array: number[]): Effect;
  34722. /**
  34723. * Sets matrices on a uniform variable.
  34724. * @param uniformName Name of the variable.
  34725. * @param matrices matrices to be set.
  34726. * @returns this effect.
  34727. */
  34728. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  34729. /**
  34730. * Sets matrix on a uniform variable.
  34731. * @param uniformName Name of the variable.
  34732. * @param matrix matrix to be set.
  34733. * @returns this effect.
  34734. */
  34735. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  34736. /**
  34737. * 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)
  34738. * @param uniformName Name of the variable.
  34739. * @param matrix matrix to be set.
  34740. * @returns this effect.
  34741. */
  34742. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34743. /**
  34744. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  34745. * @param uniformName Name of the variable.
  34746. * @param matrix matrix to be set.
  34747. * @returns this effect.
  34748. */
  34749. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34750. /**
  34751. * Sets a float on a uniform variable.
  34752. * @param uniformName Name of the variable.
  34753. * @param value value to be set.
  34754. * @returns this effect.
  34755. */
  34756. setFloat(uniformName: string, value: number): Effect;
  34757. /**
  34758. * Sets a boolean on a uniform variable.
  34759. * @param uniformName Name of the variable.
  34760. * @param bool value to be set.
  34761. * @returns this effect.
  34762. */
  34763. setBool(uniformName: string, bool: boolean): Effect;
  34764. /**
  34765. * Sets a Vector2 on a uniform variable.
  34766. * @param uniformName Name of the variable.
  34767. * @param vector2 vector2 to be set.
  34768. * @returns this effect.
  34769. */
  34770. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  34771. /**
  34772. * Sets a float2 on a uniform variable.
  34773. * @param uniformName Name of the variable.
  34774. * @param x First float in float2.
  34775. * @param y Second float in float2.
  34776. * @returns this effect.
  34777. */
  34778. setFloat2(uniformName: string, x: number, y: number): Effect;
  34779. /**
  34780. * Sets a Vector3 on a uniform variable.
  34781. * @param uniformName Name of the variable.
  34782. * @param vector3 Value to be set.
  34783. * @returns this effect.
  34784. */
  34785. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  34786. /**
  34787. * Sets a float3 on a uniform variable.
  34788. * @param uniformName Name of the variable.
  34789. * @param x First float in float3.
  34790. * @param y Second float in float3.
  34791. * @param z Third float in float3.
  34792. * @returns this effect.
  34793. */
  34794. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  34795. /**
  34796. * Sets a Vector4 on a uniform variable.
  34797. * @param uniformName Name of the variable.
  34798. * @param vector4 Value to be set.
  34799. * @returns this effect.
  34800. */
  34801. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  34802. /**
  34803. * Sets a float4 on a uniform variable.
  34804. * @param uniformName Name of the variable.
  34805. * @param x First float in float4.
  34806. * @param y Second float in float4.
  34807. * @param z Third float in float4.
  34808. * @param w Fourth float in float4.
  34809. * @returns this effect.
  34810. */
  34811. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  34812. /**
  34813. * Sets a Color3 on a uniform variable.
  34814. * @param uniformName Name of the variable.
  34815. * @param color3 Value to be set.
  34816. * @returns this effect.
  34817. */
  34818. setColor3(uniformName: string, color3: IColor3Like): Effect;
  34819. /**
  34820. * Sets a Color4 on a uniform variable.
  34821. * @param uniformName Name of the variable.
  34822. * @param color3 Value to be set.
  34823. * @param alpha Alpha value to be set.
  34824. * @returns this effect.
  34825. */
  34826. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  34827. /**
  34828. * Sets a Color4 on a uniform variable
  34829. * @param uniformName defines the name of the variable
  34830. * @param color4 defines the value to be set
  34831. * @returns this effect.
  34832. */
  34833. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  34834. /** Release all associated resources */
  34835. dispose(): void;
  34836. /**
  34837. * This function will add a new shader to the shader store
  34838. * @param name the name of the shader
  34839. * @param pixelShader optional pixel shader content
  34840. * @param vertexShader optional vertex shader content
  34841. */
  34842. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  34843. /**
  34844. * Store of each shader (The can be looked up using effect.key)
  34845. */
  34846. static ShadersStore: {
  34847. [key: string]: string;
  34848. };
  34849. /**
  34850. * Store of each included file for a shader (The can be looked up using effect.key)
  34851. */
  34852. static IncludesShadersStore: {
  34853. [key: string]: string;
  34854. };
  34855. /**
  34856. * Resets the cache of effects.
  34857. */
  34858. static ResetCache(): void;
  34859. }
  34860. }
  34861. declare module BABYLON {
  34862. /**
  34863. * Interface used to describe the capabilities of the engine relatively to the current browser
  34864. */
  34865. export interface EngineCapabilities {
  34866. /** Maximum textures units per fragment shader */
  34867. maxTexturesImageUnits: number;
  34868. /** Maximum texture units per vertex shader */
  34869. maxVertexTextureImageUnits: number;
  34870. /** Maximum textures units in the entire pipeline */
  34871. maxCombinedTexturesImageUnits: number;
  34872. /** Maximum texture size */
  34873. maxTextureSize: number;
  34874. /** Maximum texture samples */
  34875. maxSamples?: number;
  34876. /** Maximum cube texture size */
  34877. maxCubemapTextureSize: number;
  34878. /** Maximum render texture size */
  34879. maxRenderTextureSize: number;
  34880. /** Maximum number of vertex attributes */
  34881. maxVertexAttribs: number;
  34882. /** Maximum number of varyings */
  34883. maxVaryingVectors: number;
  34884. /** Maximum number of uniforms per vertex shader */
  34885. maxVertexUniformVectors: number;
  34886. /** Maximum number of uniforms per fragment shader */
  34887. maxFragmentUniformVectors: number;
  34888. /** Defines if standard derivates (dx/dy) are supported */
  34889. standardDerivatives: boolean;
  34890. /** Defines if s3tc texture compression is supported */
  34891. s3tc?: WEBGL_compressed_texture_s3tc;
  34892. /** Defines if pvrtc texture compression is supported */
  34893. pvrtc: any;
  34894. /** Defines if etc1 texture compression is supported */
  34895. etc1: any;
  34896. /** Defines if etc2 texture compression is supported */
  34897. etc2: any;
  34898. /** Defines if astc texture compression is supported */
  34899. astc: any;
  34900. /** Defines if bptc texture compression is supported */
  34901. bptc: any;
  34902. /** Defines if float textures are supported */
  34903. textureFloat: boolean;
  34904. /** Defines if vertex array objects are supported */
  34905. vertexArrayObject: boolean;
  34906. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  34907. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  34908. /** Gets the maximum level of anisotropy supported */
  34909. maxAnisotropy: number;
  34910. /** Defines if instancing is supported */
  34911. instancedArrays: boolean;
  34912. /** Defines if 32 bits indices are supported */
  34913. uintIndices: boolean;
  34914. /** Defines if high precision shaders are supported */
  34915. highPrecisionShaderSupported: boolean;
  34916. /** Defines if depth reading in the fragment shader is supported */
  34917. fragmentDepthSupported: boolean;
  34918. /** Defines if float texture linear filtering is supported*/
  34919. textureFloatLinearFiltering: boolean;
  34920. /** Defines if rendering to float textures is supported */
  34921. textureFloatRender: boolean;
  34922. /** Defines if half float textures are supported*/
  34923. textureHalfFloat: boolean;
  34924. /** Defines if half float texture linear filtering is supported*/
  34925. textureHalfFloatLinearFiltering: boolean;
  34926. /** Defines if rendering to half float textures is supported */
  34927. textureHalfFloatRender: boolean;
  34928. /** Defines if textureLOD shader command is supported */
  34929. textureLOD: boolean;
  34930. /** Defines if draw buffers extension is supported */
  34931. drawBuffersExtension: boolean;
  34932. /** Defines if depth textures are supported */
  34933. depthTextureExtension: boolean;
  34934. /** Defines if float color buffer are supported */
  34935. colorBufferFloat: boolean;
  34936. /** Gets disjoint timer query extension (null if not supported) */
  34937. timerQuery?: EXT_disjoint_timer_query;
  34938. /** Defines if timestamp can be used with timer query */
  34939. canUseTimestampForTimerQuery: boolean;
  34940. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  34941. multiview?: any;
  34942. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  34943. oculusMultiview?: any;
  34944. /** Function used to let the system compiles shaders in background */
  34945. parallelShaderCompile?: {
  34946. COMPLETION_STATUS_KHR: number;
  34947. };
  34948. /** Max number of texture samples for MSAA */
  34949. maxMSAASamples: number;
  34950. /** Defines if the blend min max extension is supported */
  34951. blendMinMax: boolean;
  34952. }
  34953. }
  34954. declare module BABYLON {
  34955. /**
  34956. * @hidden
  34957. **/
  34958. export class DepthCullingState {
  34959. private _isDepthTestDirty;
  34960. private _isDepthMaskDirty;
  34961. private _isDepthFuncDirty;
  34962. private _isCullFaceDirty;
  34963. private _isCullDirty;
  34964. private _isZOffsetDirty;
  34965. private _isFrontFaceDirty;
  34966. private _depthTest;
  34967. private _depthMask;
  34968. private _depthFunc;
  34969. private _cull;
  34970. private _cullFace;
  34971. private _zOffset;
  34972. private _frontFace;
  34973. /**
  34974. * Initializes the state.
  34975. */
  34976. constructor();
  34977. get isDirty(): boolean;
  34978. get zOffset(): number;
  34979. set zOffset(value: number);
  34980. get cullFace(): Nullable<number>;
  34981. set cullFace(value: Nullable<number>);
  34982. get cull(): Nullable<boolean>;
  34983. set cull(value: Nullable<boolean>);
  34984. get depthFunc(): Nullable<number>;
  34985. set depthFunc(value: Nullable<number>);
  34986. get depthMask(): boolean;
  34987. set depthMask(value: boolean);
  34988. get depthTest(): boolean;
  34989. set depthTest(value: boolean);
  34990. get frontFace(): Nullable<number>;
  34991. set frontFace(value: Nullable<number>);
  34992. reset(): void;
  34993. apply(gl: WebGLRenderingContext): void;
  34994. }
  34995. }
  34996. declare module BABYLON {
  34997. /**
  34998. * @hidden
  34999. **/
  35000. export class StencilState {
  35001. /** 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 */
  35002. static readonly ALWAYS: number;
  35003. /** Passed to stencilOperation to specify that stencil value must be kept */
  35004. static readonly KEEP: number;
  35005. /** Passed to stencilOperation to specify that stencil value must be replaced */
  35006. static readonly REPLACE: number;
  35007. private _isStencilTestDirty;
  35008. private _isStencilMaskDirty;
  35009. private _isStencilFuncDirty;
  35010. private _isStencilOpDirty;
  35011. private _stencilTest;
  35012. private _stencilMask;
  35013. private _stencilFunc;
  35014. private _stencilFuncRef;
  35015. private _stencilFuncMask;
  35016. private _stencilOpStencilFail;
  35017. private _stencilOpDepthFail;
  35018. private _stencilOpStencilDepthPass;
  35019. get isDirty(): boolean;
  35020. get stencilFunc(): number;
  35021. set stencilFunc(value: number);
  35022. get stencilFuncRef(): number;
  35023. set stencilFuncRef(value: number);
  35024. get stencilFuncMask(): number;
  35025. set stencilFuncMask(value: number);
  35026. get stencilOpStencilFail(): number;
  35027. set stencilOpStencilFail(value: number);
  35028. get stencilOpDepthFail(): number;
  35029. set stencilOpDepthFail(value: number);
  35030. get stencilOpStencilDepthPass(): number;
  35031. set stencilOpStencilDepthPass(value: number);
  35032. get stencilMask(): number;
  35033. set stencilMask(value: number);
  35034. get stencilTest(): boolean;
  35035. set stencilTest(value: boolean);
  35036. constructor();
  35037. reset(): void;
  35038. apply(gl: WebGLRenderingContext): void;
  35039. }
  35040. }
  35041. declare module BABYLON {
  35042. /**
  35043. * @hidden
  35044. **/
  35045. export class AlphaState {
  35046. private _isAlphaBlendDirty;
  35047. private _isBlendFunctionParametersDirty;
  35048. private _isBlendEquationParametersDirty;
  35049. private _isBlendConstantsDirty;
  35050. private _alphaBlend;
  35051. private _blendFunctionParameters;
  35052. private _blendEquationParameters;
  35053. private _blendConstants;
  35054. /**
  35055. * Initializes the state.
  35056. */
  35057. constructor();
  35058. get isDirty(): boolean;
  35059. get alphaBlend(): boolean;
  35060. set alphaBlend(value: boolean);
  35061. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  35062. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  35063. setAlphaEquationParameters(rgb: number, alpha: number): void;
  35064. reset(): void;
  35065. apply(gl: WebGLRenderingContext): void;
  35066. }
  35067. }
  35068. declare module BABYLON {
  35069. /** @hidden */
  35070. export class WebGL2ShaderProcessor implements IShaderProcessor {
  35071. attributeProcessor(attribute: string): string;
  35072. varyingProcessor(varying: string, isFragment: boolean): string;
  35073. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  35074. }
  35075. }
  35076. declare module BABYLON {
  35077. /**
  35078. * Interface for attribute information associated with buffer instanciation
  35079. */
  35080. export interface InstancingAttributeInfo {
  35081. /**
  35082. * Name of the GLSL attribute
  35083. * if attribute index is not specified, this is used to retrieve the index from the effect
  35084. */
  35085. attributeName: string;
  35086. /**
  35087. * Index/offset of the attribute in the vertex shader
  35088. * if not specified, this will be computes from the name.
  35089. */
  35090. index?: number;
  35091. /**
  35092. * size of the attribute, 1, 2, 3 or 4
  35093. */
  35094. attributeSize: number;
  35095. /**
  35096. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  35097. */
  35098. offset: number;
  35099. /**
  35100. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  35101. * default to 1
  35102. */
  35103. divisor?: number;
  35104. /**
  35105. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  35106. * default is FLOAT
  35107. */
  35108. attributeType?: number;
  35109. /**
  35110. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  35111. */
  35112. normalized?: boolean;
  35113. }
  35114. }
  35115. declare module BABYLON {
  35116. interface ThinEngine {
  35117. /**
  35118. * Update a video texture
  35119. * @param texture defines the texture to update
  35120. * @param video defines the video element to use
  35121. * @param invertY defines if data must be stored with Y axis inverted
  35122. */
  35123. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  35124. }
  35125. }
  35126. declare module BABYLON {
  35127. interface ThinEngine {
  35128. /**
  35129. * Creates a dynamic texture
  35130. * @param width defines the width of the texture
  35131. * @param height defines the height of the texture
  35132. * @param generateMipMaps defines if the engine should generate the mip levels
  35133. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  35134. * @returns the dynamic texture inside an InternalTexture
  35135. */
  35136. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  35137. /**
  35138. * Update the content of a dynamic texture
  35139. * @param texture defines the texture to update
  35140. * @param canvas defines the canvas containing the source
  35141. * @param invertY defines if data must be stored with Y axis inverted
  35142. * @param premulAlpha defines if alpha is stored as premultiplied
  35143. * @param format defines the format of the data
  35144. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  35145. */
  35146. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  35147. }
  35148. }
  35149. declare module BABYLON {
  35150. /**
  35151. * Settings for finer control over video usage
  35152. */
  35153. export interface VideoTextureSettings {
  35154. /**
  35155. * Applies `autoplay` to video, if specified
  35156. */
  35157. autoPlay?: boolean;
  35158. /**
  35159. * Applies `loop` to video, if specified
  35160. */
  35161. loop?: boolean;
  35162. /**
  35163. * Automatically updates internal texture from video at every frame in the render loop
  35164. */
  35165. autoUpdateTexture: boolean;
  35166. /**
  35167. * Image src displayed during the video loading or until the user interacts with the video.
  35168. */
  35169. poster?: string;
  35170. }
  35171. /**
  35172. * If you want to display a video in your scene, this is the special texture for that.
  35173. * This special texture works similar to other textures, with the exception of a few parameters.
  35174. * @see https://doc.babylonjs.com/how_to/video_texture
  35175. */
  35176. export class VideoTexture extends Texture {
  35177. /**
  35178. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  35179. */
  35180. readonly autoUpdateTexture: boolean;
  35181. /**
  35182. * The video instance used by the texture internally
  35183. */
  35184. readonly video: HTMLVideoElement;
  35185. private _onUserActionRequestedObservable;
  35186. /**
  35187. * Event triggerd when a dom action is required by the user to play the video.
  35188. * This happens due to recent changes in browser policies preventing video to auto start.
  35189. */
  35190. get onUserActionRequestedObservable(): Observable<Texture>;
  35191. private _generateMipMaps;
  35192. private _stillImageCaptured;
  35193. private _displayingPosterTexture;
  35194. private _settings;
  35195. private _createInternalTextureOnEvent;
  35196. private _frameId;
  35197. private _currentSrc;
  35198. /**
  35199. * Creates a video texture.
  35200. * If you want to display a video in your scene, this is the special texture for that.
  35201. * This special texture works similar to other textures, with the exception of a few parameters.
  35202. * @see https://doc.babylonjs.com/how_to/video_texture
  35203. * @param name optional name, will detect from video source, if not defined
  35204. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  35205. * @param scene is obviously the current scene.
  35206. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  35207. * @param invertY is false by default but can be used to invert video on Y axis
  35208. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  35209. * @param settings allows finer control over video usage
  35210. */
  35211. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  35212. private _getName;
  35213. private _getVideo;
  35214. private _createInternalTexture;
  35215. private reset;
  35216. /**
  35217. * @hidden Internal method to initiate `update`.
  35218. */
  35219. _rebuild(): void;
  35220. /**
  35221. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  35222. */
  35223. update(): void;
  35224. /**
  35225. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  35226. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  35227. */
  35228. updateTexture(isVisible: boolean): void;
  35229. protected _updateInternalTexture: () => void;
  35230. /**
  35231. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  35232. * @param url New url.
  35233. */
  35234. updateURL(url: string): void;
  35235. /**
  35236. * Clones the texture.
  35237. * @returns the cloned texture
  35238. */
  35239. clone(): VideoTexture;
  35240. /**
  35241. * Dispose the texture and release its associated resources.
  35242. */
  35243. dispose(): void;
  35244. /**
  35245. * Creates a video texture straight from a stream.
  35246. * @param scene Define the scene the texture should be created in
  35247. * @param stream Define the stream the texture should be created from
  35248. * @returns The created video texture as a promise
  35249. */
  35250. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  35251. /**
  35252. * Creates a video texture straight from your WebCam video feed.
  35253. * @param scene Define the scene the texture should be created in
  35254. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35255. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35256. * @returns The created video texture as a promise
  35257. */
  35258. static CreateFromWebCamAsync(scene: Scene, constraints: {
  35259. minWidth: number;
  35260. maxWidth: number;
  35261. minHeight: number;
  35262. maxHeight: number;
  35263. deviceId: string;
  35264. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  35265. /**
  35266. * Creates a video texture straight from your WebCam video feed.
  35267. * @param scene Define the scene the texture should be created in
  35268. * @param onReady Define a callback to triggered once the texture will be ready
  35269. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35270. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35271. */
  35272. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  35273. minWidth: number;
  35274. maxWidth: number;
  35275. minHeight: number;
  35276. maxHeight: number;
  35277. deviceId: string;
  35278. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  35279. }
  35280. }
  35281. declare module BABYLON {
  35282. /**
  35283. * Defines the interface used by objects working like Scene
  35284. * @hidden
  35285. */
  35286. export interface ISceneLike {
  35287. _addPendingData(data: any): void;
  35288. _removePendingData(data: any): void;
  35289. offlineProvider: IOfflineProvider;
  35290. }
  35291. /**
  35292. * Information about the current host
  35293. */
  35294. export interface HostInformation {
  35295. /**
  35296. * Defines if the current host is a mobile
  35297. */
  35298. isMobile: boolean;
  35299. }
  35300. /** Interface defining initialization parameters for Engine class */
  35301. export interface EngineOptions extends WebGLContextAttributes {
  35302. /**
  35303. * Defines if the engine should no exceed a specified device ratio
  35304. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  35305. */
  35306. limitDeviceRatio?: number;
  35307. /**
  35308. * Defines if webvr should be enabled automatically
  35309. * @see https://doc.babylonjs.com/how_to/webvr_camera
  35310. */
  35311. autoEnableWebVR?: boolean;
  35312. /**
  35313. * Defines if webgl2 should be turned off even if supported
  35314. * @see https://doc.babylonjs.com/features/webgl2
  35315. */
  35316. disableWebGL2Support?: boolean;
  35317. /**
  35318. * Defines if webaudio should be initialized as well
  35319. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  35320. */
  35321. audioEngine?: boolean;
  35322. /**
  35323. * Defines if animations should run using a deterministic lock step
  35324. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35325. */
  35326. deterministicLockstep?: boolean;
  35327. /** Defines the maximum steps to use with deterministic lock step mode */
  35328. lockstepMaxSteps?: number;
  35329. /** Defines the seconds between each deterministic lock step */
  35330. timeStep?: number;
  35331. /**
  35332. * Defines that engine should ignore context lost events
  35333. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  35334. */
  35335. doNotHandleContextLost?: boolean;
  35336. /**
  35337. * Defines that engine should ignore modifying touch action attribute and style
  35338. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  35339. */
  35340. doNotHandleTouchAction?: boolean;
  35341. /**
  35342. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  35343. */
  35344. useHighPrecisionFloats?: boolean;
  35345. /**
  35346. * Make the canvas XR Compatible for XR sessions
  35347. */
  35348. xrCompatible?: boolean;
  35349. /**
  35350. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  35351. */
  35352. useHighPrecisionMatrix?: boolean;
  35353. }
  35354. /**
  35355. * The base engine class (root of all engines)
  35356. */
  35357. export class ThinEngine {
  35358. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  35359. static ExceptionList: ({
  35360. key: string;
  35361. capture: string;
  35362. captureConstraint: number;
  35363. targets: string[];
  35364. } | {
  35365. key: string;
  35366. capture: null;
  35367. captureConstraint: null;
  35368. targets: string[];
  35369. })[];
  35370. /** @hidden */
  35371. static _TextureLoaders: IInternalTextureLoader[];
  35372. /**
  35373. * Returns the current npm package of the sdk
  35374. */
  35375. static get NpmPackage(): string;
  35376. /**
  35377. * Returns the current version of the framework
  35378. */
  35379. static get Version(): string;
  35380. /**
  35381. * Returns a string describing the current engine
  35382. */
  35383. get description(): string;
  35384. /**
  35385. * Gets or sets the epsilon value used by collision engine
  35386. */
  35387. static CollisionsEpsilon: number;
  35388. /**
  35389. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35390. */
  35391. static get ShadersRepository(): string;
  35392. static set ShadersRepository(value: string);
  35393. /** @hidden */
  35394. _shaderProcessor: IShaderProcessor;
  35395. /**
  35396. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  35397. */
  35398. forcePOTTextures: boolean;
  35399. /**
  35400. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  35401. */
  35402. isFullscreen: boolean;
  35403. /**
  35404. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  35405. */
  35406. cullBackFaces: boolean;
  35407. /**
  35408. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  35409. */
  35410. renderEvenInBackground: boolean;
  35411. /**
  35412. * Gets or sets a boolean indicating that cache can be kept between frames
  35413. */
  35414. preventCacheWipeBetweenFrames: boolean;
  35415. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  35416. validateShaderPrograms: boolean;
  35417. /**
  35418. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  35419. * This can provide greater z depth for distant objects.
  35420. */
  35421. useReverseDepthBuffer: boolean;
  35422. /**
  35423. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  35424. */
  35425. disableUniformBuffers: boolean;
  35426. /** @hidden */
  35427. _uniformBuffers: UniformBuffer[];
  35428. /**
  35429. * Gets a boolean indicating that the engine supports uniform buffers
  35430. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  35431. */
  35432. get supportsUniformBuffers(): boolean;
  35433. /** @hidden */
  35434. _gl: WebGLRenderingContext;
  35435. /** @hidden */
  35436. _webGLVersion: number;
  35437. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  35438. protected _windowIsBackground: boolean;
  35439. protected _creationOptions: EngineOptions;
  35440. protected _highPrecisionShadersAllowed: boolean;
  35441. /** @hidden */
  35442. get _shouldUseHighPrecisionShader(): boolean;
  35443. /**
  35444. * Gets a boolean indicating that only power of 2 textures are supported
  35445. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  35446. */
  35447. get needPOTTextures(): boolean;
  35448. /** @hidden */
  35449. _badOS: boolean;
  35450. /** @hidden */
  35451. _badDesktopOS: boolean;
  35452. private _hardwareScalingLevel;
  35453. /** @hidden */
  35454. _caps: EngineCapabilities;
  35455. private _isStencilEnable;
  35456. private _glVersion;
  35457. private _glRenderer;
  35458. private _glVendor;
  35459. /** @hidden */
  35460. _videoTextureSupported: boolean;
  35461. protected _renderingQueueLaunched: boolean;
  35462. protected _activeRenderLoops: (() => void)[];
  35463. /**
  35464. * Observable signaled when a context lost event is raised
  35465. */
  35466. onContextLostObservable: Observable<ThinEngine>;
  35467. /**
  35468. * Observable signaled when a context restored event is raised
  35469. */
  35470. onContextRestoredObservable: Observable<ThinEngine>;
  35471. private _onContextLost;
  35472. private _onContextRestored;
  35473. protected _contextWasLost: boolean;
  35474. /** @hidden */
  35475. _doNotHandleContextLost: boolean;
  35476. /**
  35477. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  35478. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  35479. */
  35480. get doNotHandleContextLost(): boolean;
  35481. set doNotHandleContextLost(value: boolean);
  35482. /**
  35483. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  35484. */
  35485. disableVertexArrayObjects: boolean;
  35486. /** @hidden */
  35487. protected _colorWrite: boolean;
  35488. /** @hidden */
  35489. protected _colorWriteChanged: boolean;
  35490. /** @hidden */
  35491. protected _depthCullingState: DepthCullingState;
  35492. /** @hidden */
  35493. protected _stencilState: StencilState;
  35494. /** @hidden */
  35495. _alphaState: AlphaState;
  35496. /** @hidden */
  35497. _alphaMode: number;
  35498. /** @hidden */
  35499. _alphaEquation: number;
  35500. /** @hidden */
  35501. _internalTexturesCache: InternalTexture[];
  35502. /** @hidden */
  35503. protected _activeChannel: number;
  35504. private _currentTextureChannel;
  35505. /** @hidden */
  35506. protected _boundTexturesCache: {
  35507. [key: string]: Nullable<InternalTexture>;
  35508. };
  35509. /** @hidden */
  35510. protected _currentEffect: Nullable<Effect>;
  35511. /** @hidden */
  35512. protected _currentProgram: Nullable<WebGLProgram>;
  35513. private _compiledEffects;
  35514. private _vertexAttribArraysEnabled;
  35515. /** @hidden */
  35516. protected _cachedViewport: Nullable<IViewportLike>;
  35517. private _cachedVertexArrayObject;
  35518. /** @hidden */
  35519. protected _cachedVertexBuffers: any;
  35520. /** @hidden */
  35521. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  35522. /** @hidden */
  35523. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  35524. /** @hidden */
  35525. _currentRenderTarget: Nullable<InternalTexture>;
  35526. private _uintIndicesCurrentlySet;
  35527. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  35528. /** @hidden */
  35529. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  35530. /** @hidden */
  35531. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  35532. private _currentBufferPointers;
  35533. private _currentInstanceLocations;
  35534. private _currentInstanceBuffers;
  35535. private _textureUnits;
  35536. /** @hidden */
  35537. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35538. /** @hidden */
  35539. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35540. /** @hidden */
  35541. _boundRenderFunction: any;
  35542. private _vaoRecordInProgress;
  35543. private _mustWipeVertexAttributes;
  35544. private _emptyTexture;
  35545. private _emptyCubeTexture;
  35546. private _emptyTexture3D;
  35547. private _emptyTexture2DArray;
  35548. /** @hidden */
  35549. _frameHandler: number;
  35550. private _nextFreeTextureSlots;
  35551. private _maxSimultaneousTextures;
  35552. private _activeRequests;
  35553. /** @hidden */
  35554. _transformTextureUrl: Nullable<(url: string) => string>;
  35555. /**
  35556. * Gets information about the current host
  35557. */
  35558. hostInformation: HostInformation;
  35559. protected get _supportsHardwareTextureRescaling(): boolean;
  35560. private _framebufferDimensionsObject;
  35561. /**
  35562. * sets the object from which width and height will be taken from when getting render width and height
  35563. * Will fallback to the gl object
  35564. * @param dimensions the framebuffer width and height that will be used.
  35565. */
  35566. set framebufferDimensionsObject(dimensions: Nullable<{
  35567. framebufferWidth: number;
  35568. framebufferHeight: number;
  35569. }>);
  35570. /**
  35571. * Gets the current viewport
  35572. */
  35573. get currentViewport(): Nullable<IViewportLike>;
  35574. /**
  35575. * Gets the default empty texture
  35576. */
  35577. get emptyTexture(): InternalTexture;
  35578. /**
  35579. * Gets the default empty 3D texture
  35580. */
  35581. get emptyTexture3D(): InternalTexture;
  35582. /**
  35583. * Gets the default empty 2D array texture
  35584. */
  35585. get emptyTexture2DArray(): InternalTexture;
  35586. /**
  35587. * Gets the default empty cube texture
  35588. */
  35589. get emptyCubeTexture(): InternalTexture;
  35590. /**
  35591. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  35592. */
  35593. readonly premultipliedAlpha: boolean;
  35594. /**
  35595. * Observable event triggered before each texture is initialized
  35596. */
  35597. onBeforeTextureInitObservable: Observable<Texture>;
  35598. /**
  35599. * Creates a new engine
  35600. * @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
  35601. * @param antialias defines enable antialiasing (default: false)
  35602. * @param options defines further options to be sent to the getContext() function
  35603. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  35604. */
  35605. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  35606. private _rebuildInternalTextures;
  35607. private _rebuildEffects;
  35608. /**
  35609. * Gets a boolean indicating if all created effects are ready
  35610. * @returns true if all effects are ready
  35611. */
  35612. areAllEffectsReady(): boolean;
  35613. protected _rebuildBuffers(): void;
  35614. protected _initGLContext(): void;
  35615. /**
  35616. * Gets version of the current webGL context
  35617. */
  35618. get webGLVersion(): number;
  35619. /**
  35620. * Gets a string identifying the name of the class
  35621. * @returns "Engine" string
  35622. */
  35623. getClassName(): string;
  35624. /**
  35625. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  35626. */
  35627. get isStencilEnable(): boolean;
  35628. /** @hidden */
  35629. _prepareWorkingCanvas(): void;
  35630. /**
  35631. * Reset the texture cache to empty state
  35632. */
  35633. resetTextureCache(): void;
  35634. /**
  35635. * Gets an object containing information about the current webGL context
  35636. * @returns an object containing the vender, the renderer and the version of the current webGL context
  35637. */
  35638. getGlInfo(): {
  35639. vendor: string;
  35640. renderer: string;
  35641. version: string;
  35642. };
  35643. /**
  35644. * Defines the hardware scaling level.
  35645. * By default the hardware scaling level is computed from the window device ratio.
  35646. * 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.
  35647. * @param level defines the level to use
  35648. */
  35649. setHardwareScalingLevel(level: number): void;
  35650. /**
  35651. * Gets the current hardware scaling level.
  35652. * By default the hardware scaling level is computed from the window device ratio.
  35653. * 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.
  35654. * @returns a number indicating the current hardware scaling level
  35655. */
  35656. getHardwareScalingLevel(): number;
  35657. /**
  35658. * Gets the list of loaded textures
  35659. * @returns an array containing all loaded textures
  35660. */
  35661. getLoadedTexturesCache(): InternalTexture[];
  35662. /**
  35663. * Gets the object containing all engine capabilities
  35664. * @returns the EngineCapabilities object
  35665. */
  35666. getCaps(): EngineCapabilities;
  35667. /**
  35668. * stop executing a render loop function and remove it from the execution array
  35669. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  35670. */
  35671. stopRenderLoop(renderFunction?: () => void): void;
  35672. /** @hidden */
  35673. _renderLoop(): void;
  35674. /**
  35675. * Gets the HTML canvas attached with the current webGL context
  35676. * @returns a HTML canvas
  35677. */
  35678. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  35679. /**
  35680. * Gets host window
  35681. * @returns the host window object
  35682. */
  35683. getHostWindow(): Nullable<Window>;
  35684. /**
  35685. * Gets the current render width
  35686. * @param useScreen defines if screen size must be used (or the current render target if any)
  35687. * @returns a number defining the current render width
  35688. */
  35689. getRenderWidth(useScreen?: boolean): number;
  35690. /**
  35691. * Gets the current render height
  35692. * @param useScreen defines if screen size must be used (or the current render target if any)
  35693. * @returns a number defining the current render height
  35694. */
  35695. getRenderHeight(useScreen?: boolean): number;
  35696. /**
  35697. * Can be used to override the current requestAnimationFrame requester.
  35698. * @hidden
  35699. */
  35700. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  35701. /**
  35702. * Register and execute a render loop. The engine can have more than one render function
  35703. * @param renderFunction defines the function to continuously execute
  35704. */
  35705. runRenderLoop(renderFunction: () => void): void;
  35706. /**
  35707. * Clear the current render buffer or the current render target (if any is set up)
  35708. * @param color defines the color to use
  35709. * @param backBuffer defines if the back buffer must be cleared
  35710. * @param depth defines if the depth buffer must be cleared
  35711. * @param stencil defines if the stencil buffer must be cleared
  35712. */
  35713. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  35714. private _viewportCached;
  35715. /** @hidden */
  35716. _viewport(x: number, y: number, width: number, height: number): void;
  35717. /**
  35718. * Set the WebGL's viewport
  35719. * @param viewport defines the viewport element to be used
  35720. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  35721. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  35722. */
  35723. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  35724. /**
  35725. * Begin a new frame
  35726. */
  35727. beginFrame(): void;
  35728. /**
  35729. * Enf the current frame
  35730. */
  35731. endFrame(): void;
  35732. /**
  35733. * Resize the view according to the canvas' size
  35734. */
  35735. resize(): void;
  35736. /**
  35737. * Force a specific size of the canvas
  35738. * @param width defines the new canvas' width
  35739. * @param height defines the new canvas' height
  35740. * @returns true if the size was changed
  35741. */
  35742. setSize(width: number, height: number): boolean;
  35743. /**
  35744. * Binds the frame buffer to the specified texture.
  35745. * @param texture The texture to render to or null for the default canvas
  35746. * @param faceIndex The face of the texture to render to in case of cube texture
  35747. * @param requiredWidth The width of the target to render to
  35748. * @param requiredHeight The height of the target to render to
  35749. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  35750. * @param lodLevel defines the lod level to bind to the frame buffer
  35751. * @param layer defines the 2d array index to bind to frame buffer to
  35752. */
  35753. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  35754. /** @hidden */
  35755. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  35756. /**
  35757. * Unbind the current render target texture from the webGL context
  35758. * @param texture defines the render target texture to unbind
  35759. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  35760. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  35761. */
  35762. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  35763. /**
  35764. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  35765. */
  35766. flushFramebuffer(): void;
  35767. /**
  35768. * Unbind the current render target and bind the default framebuffer
  35769. */
  35770. restoreDefaultFramebuffer(): void;
  35771. /** @hidden */
  35772. protected _resetVertexBufferBinding(): void;
  35773. /**
  35774. * Creates a vertex buffer
  35775. * @param data the data for the vertex buffer
  35776. * @returns the new WebGL static buffer
  35777. */
  35778. createVertexBuffer(data: DataArray): DataBuffer;
  35779. private _createVertexBuffer;
  35780. /**
  35781. * Creates a dynamic vertex buffer
  35782. * @param data the data for the dynamic vertex buffer
  35783. * @returns the new WebGL dynamic buffer
  35784. */
  35785. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  35786. protected _resetIndexBufferBinding(): void;
  35787. /**
  35788. * Creates a new index buffer
  35789. * @param indices defines the content of the index buffer
  35790. * @param updatable defines if the index buffer must be updatable
  35791. * @returns a new webGL buffer
  35792. */
  35793. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  35794. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  35795. /**
  35796. * Bind a webGL buffer to the webGL context
  35797. * @param buffer defines the buffer to bind
  35798. */
  35799. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  35800. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  35801. private bindBuffer;
  35802. /**
  35803. * update the bound buffer with the given data
  35804. * @param data defines the data to update
  35805. */
  35806. updateArrayBuffer(data: Float32Array): void;
  35807. private _vertexAttribPointer;
  35808. /** @hidden */
  35809. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  35810. private _bindVertexBuffersAttributes;
  35811. /**
  35812. * Records a vertex array object
  35813. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35814. * @param vertexBuffers defines the list of vertex buffers to store
  35815. * @param indexBuffer defines the index buffer to store
  35816. * @param effect defines the effect to store
  35817. * @returns the new vertex array object
  35818. */
  35819. recordVertexArrayObject(vertexBuffers: {
  35820. [key: string]: VertexBuffer;
  35821. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  35822. /**
  35823. * Bind a specific vertex array object
  35824. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35825. * @param vertexArrayObject defines the vertex array object to bind
  35826. * @param indexBuffer defines the index buffer to bind
  35827. */
  35828. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  35829. /**
  35830. * Bind webGl buffers directly to the webGL context
  35831. * @param vertexBuffer defines the vertex buffer to bind
  35832. * @param indexBuffer defines the index buffer to bind
  35833. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  35834. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  35835. * @param effect defines the effect associated with the vertex buffer
  35836. */
  35837. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  35838. private _unbindVertexArrayObject;
  35839. /**
  35840. * Bind a list of vertex buffers to the webGL context
  35841. * @param vertexBuffers defines the list of vertex buffers to bind
  35842. * @param indexBuffer defines the index buffer to bind
  35843. * @param effect defines the effect associated with the vertex buffers
  35844. */
  35845. bindBuffers(vertexBuffers: {
  35846. [key: string]: Nullable<VertexBuffer>;
  35847. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  35848. /**
  35849. * Unbind all instance attributes
  35850. */
  35851. unbindInstanceAttributes(): void;
  35852. /**
  35853. * Release and free the memory of a vertex array object
  35854. * @param vao defines the vertex array object to delete
  35855. */
  35856. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  35857. /** @hidden */
  35858. _releaseBuffer(buffer: DataBuffer): boolean;
  35859. protected _deleteBuffer(buffer: DataBuffer): void;
  35860. /**
  35861. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  35862. * @param instancesBuffer defines the webGL buffer to update and bind
  35863. * @param data defines the data to store in the buffer
  35864. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  35865. */
  35866. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  35867. /**
  35868. * Bind the content of a webGL buffer used with instantiation
  35869. * @param instancesBuffer defines the webGL buffer to bind
  35870. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  35871. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  35872. */
  35873. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  35874. /**
  35875. * Disable the instance attribute corresponding to the name in parameter
  35876. * @param name defines the name of the attribute to disable
  35877. */
  35878. disableInstanceAttributeByName(name: string): void;
  35879. /**
  35880. * Disable the instance attribute corresponding to the location in parameter
  35881. * @param attributeLocation defines the attribute location of the attribute to disable
  35882. */
  35883. disableInstanceAttribute(attributeLocation: number): void;
  35884. /**
  35885. * Disable the attribute corresponding to the location in parameter
  35886. * @param attributeLocation defines the attribute location of the attribute to disable
  35887. */
  35888. disableAttributeByIndex(attributeLocation: number): void;
  35889. /**
  35890. * Send a draw order
  35891. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35892. * @param indexStart defines the starting index
  35893. * @param indexCount defines the number of index to draw
  35894. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35895. */
  35896. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  35897. /**
  35898. * Draw a list of points
  35899. * @param verticesStart defines the index of first vertex to draw
  35900. * @param verticesCount defines the count of vertices to draw
  35901. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35902. */
  35903. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35904. /**
  35905. * Draw a list of unindexed primitives
  35906. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35907. * @param verticesStart defines the index of first vertex to draw
  35908. * @param verticesCount defines the count of vertices to draw
  35909. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35910. */
  35911. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35912. /**
  35913. * Draw a list of indexed primitives
  35914. * @param fillMode defines the primitive to use
  35915. * @param indexStart defines the starting index
  35916. * @param indexCount defines the number of index to draw
  35917. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35918. */
  35919. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  35920. /**
  35921. * Draw a list of unindexed primitives
  35922. * @param fillMode defines the primitive to use
  35923. * @param verticesStart defines the index of first vertex to draw
  35924. * @param verticesCount defines the count of vertices to draw
  35925. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35926. */
  35927. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35928. private _drawMode;
  35929. /** @hidden */
  35930. protected _reportDrawCall(): void;
  35931. /** @hidden */
  35932. _releaseEffect(effect: Effect): void;
  35933. /** @hidden */
  35934. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  35935. /**
  35936. * Create a new effect (used to store vertex/fragment shaders)
  35937. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  35938. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  35939. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  35940. * @param samplers defines an array of string used to represent textures
  35941. * @param defines defines the string containing the defines to use to compile the shaders
  35942. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  35943. * @param onCompiled defines a function to call when the effect creation is successful
  35944. * @param onError defines a function to call when the effect creation has failed
  35945. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  35946. * @returns the new Effect
  35947. */
  35948. 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;
  35949. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  35950. private _compileShader;
  35951. private _compileRawShader;
  35952. /** @hidden */
  35953. _getShaderSource(shader: WebGLShader): Nullable<string>;
  35954. /**
  35955. * Directly creates a webGL program
  35956. * @param pipelineContext defines the pipeline context to attach to
  35957. * @param vertexCode defines the vertex shader code to use
  35958. * @param fragmentCode defines the fragment shader code to use
  35959. * @param context defines the webGL context to use (if not set, the current one will be used)
  35960. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35961. * @returns the new webGL program
  35962. */
  35963. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35964. /**
  35965. * Creates a webGL program
  35966. * @param pipelineContext defines the pipeline context to attach to
  35967. * @param vertexCode defines the vertex shader code to use
  35968. * @param fragmentCode defines the fragment shader code to use
  35969. * @param defines defines the string containing the defines to use to compile the shaders
  35970. * @param context defines the webGL context to use (if not set, the current one will be used)
  35971. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35972. * @returns the new webGL program
  35973. */
  35974. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35975. /**
  35976. * Creates a new pipeline context
  35977. * @returns the new pipeline
  35978. */
  35979. createPipelineContext(): IPipelineContext;
  35980. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35981. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  35982. /** @hidden */
  35983. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  35984. /** @hidden */
  35985. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  35986. /** @hidden */
  35987. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  35988. /**
  35989. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  35990. * @param pipelineContext defines the pipeline context to use
  35991. * @param uniformsNames defines the list of uniform names
  35992. * @returns an array of webGL uniform locations
  35993. */
  35994. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  35995. /**
  35996. * Gets the lsit of active attributes for a given webGL program
  35997. * @param pipelineContext defines the pipeline context to use
  35998. * @param attributesNames defines the list of attribute names to get
  35999. * @returns an array of indices indicating the offset of each attribute
  36000. */
  36001. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  36002. /**
  36003. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  36004. * @param effect defines the effect to activate
  36005. */
  36006. enableEffect(effect: Nullable<Effect>): void;
  36007. /**
  36008. * Set the value of an uniform to a number (int)
  36009. * @param uniform defines the webGL uniform location where to store the value
  36010. * @param value defines the int number to store
  36011. * @returns true if the value was set
  36012. */
  36013. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  36014. /**
  36015. * Set the value of an uniform to an array of int32
  36016. * @param uniform defines the webGL uniform location where to store the value
  36017. * @param array defines the array of int32 to store
  36018. * @returns true if the value was set
  36019. */
  36020. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  36021. /**
  36022. * Set the value of an uniform to an array of int32 (stored as vec2)
  36023. * @param uniform defines the webGL uniform location where to store the value
  36024. * @param array defines the array of int32 to store
  36025. * @returns true if the value was set
  36026. */
  36027. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  36028. /**
  36029. * Set the value of an uniform to an array of int32 (stored as vec3)
  36030. * @param uniform defines the webGL uniform location where to store the value
  36031. * @param array defines the array of int32 to store
  36032. * @returns true if the value was set
  36033. */
  36034. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  36035. /**
  36036. * Set the value of an uniform to an array of int32 (stored as vec4)
  36037. * @param uniform defines the webGL uniform location where to store the value
  36038. * @param array defines the array of int32 to store
  36039. * @returns true if the value was set
  36040. */
  36041. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  36042. /**
  36043. * Set the value of an uniform to an array of number
  36044. * @param uniform defines the webGL uniform location where to store the value
  36045. * @param array defines the array of number to store
  36046. * @returns true if the value was set
  36047. */
  36048. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  36049. /**
  36050. * Set the value of an uniform to an array of number (stored as vec2)
  36051. * @param uniform defines the webGL uniform location where to store the value
  36052. * @param array defines the array of number to store
  36053. * @returns true if the value was set
  36054. */
  36055. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  36056. /**
  36057. * Set the value of an uniform to an array of number (stored as vec3)
  36058. * @param uniform defines the webGL uniform location where to store the value
  36059. * @param array defines the array of number to store
  36060. * @returns true if the value was set
  36061. */
  36062. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  36063. /**
  36064. * Set the value of an uniform to an array of number (stored as vec4)
  36065. * @param uniform defines the webGL uniform location where to store the value
  36066. * @param array defines the array of number to store
  36067. * @returns true if the value was set
  36068. */
  36069. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  36070. /**
  36071. * Set the value of an uniform to an array of float32 (stored as matrices)
  36072. * @param uniform defines the webGL uniform location where to store the value
  36073. * @param matrices defines the array of float32 to store
  36074. * @returns true if the value was set
  36075. */
  36076. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  36077. /**
  36078. * Set the value of an uniform to a matrix (3x3)
  36079. * @param uniform defines the webGL uniform location where to store the value
  36080. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  36081. * @returns true if the value was set
  36082. */
  36083. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  36084. /**
  36085. * Set the value of an uniform to a matrix (2x2)
  36086. * @param uniform defines the webGL uniform location where to store the value
  36087. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  36088. * @returns true if the value was set
  36089. */
  36090. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  36091. /**
  36092. * Set the value of an uniform to a number (float)
  36093. * @param uniform defines the webGL uniform location where to store the value
  36094. * @param value defines the float number to store
  36095. * @returns true if the value was transfered
  36096. */
  36097. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  36098. /**
  36099. * Set the value of an uniform to a vec2
  36100. * @param uniform defines the webGL uniform location where to store the value
  36101. * @param x defines the 1st component of the value
  36102. * @param y defines the 2nd component of the value
  36103. * @returns true if the value was set
  36104. */
  36105. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  36106. /**
  36107. * Set the value of an uniform to a vec3
  36108. * @param uniform defines the webGL uniform location where to store the value
  36109. * @param x defines the 1st component of the value
  36110. * @param y defines the 2nd component of the value
  36111. * @param z defines the 3rd component of the value
  36112. * @returns true if the value was set
  36113. */
  36114. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  36115. /**
  36116. * Set the value of an uniform to a vec4
  36117. * @param uniform defines the webGL uniform location where to store the value
  36118. * @param x defines the 1st component of the value
  36119. * @param y defines the 2nd component of the value
  36120. * @param z defines the 3rd component of the value
  36121. * @param w defines the 4th component of the value
  36122. * @returns true if the value was set
  36123. */
  36124. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  36125. /**
  36126. * Apply all cached states (depth, culling, stencil and alpha)
  36127. */
  36128. applyStates(): void;
  36129. /**
  36130. * Enable or disable color writing
  36131. * @param enable defines the state to set
  36132. */
  36133. setColorWrite(enable: boolean): void;
  36134. /**
  36135. * Gets a boolean indicating if color writing is enabled
  36136. * @returns the current color writing state
  36137. */
  36138. getColorWrite(): boolean;
  36139. /**
  36140. * Gets the depth culling state manager
  36141. */
  36142. get depthCullingState(): DepthCullingState;
  36143. /**
  36144. * Gets the alpha state manager
  36145. */
  36146. get alphaState(): AlphaState;
  36147. /**
  36148. * Gets the stencil state manager
  36149. */
  36150. get stencilState(): StencilState;
  36151. /**
  36152. * Clears the list of texture accessible through engine.
  36153. * This can help preventing texture load conflict due to name collision.
  36154. */
  36155. clearInternalTexturesCache(): void;
  36156. /**
  36157. * Force the entire cache to be cleared
  36158. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  36159. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  36160. */
  36161. wipeCaches(bruteForce?: boolean): void;
  36162. /** @hidden */
  36163. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  36164. min: number;
  36165. mag: number;
  36166. };
  36167. /** @hidden */
  36168. _createTexture(): WebGLTexture;
  36169. /**
  36170. * Usually called from Texture.ts.
  36171. * Passed information to create a WebGLTexture
  36172. * @param url defines a value which contains one of the following:
  36173. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  36174. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  36175. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  36176. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  36177. * @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)
  36178. * @param scene needed for loading to the correct scene
  36179. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  36180. * @param onLoad optional callback to be called upon successful completion
  36181. * @param onError optional callback to be called upon failure
  36182. * @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
  36183. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  36184. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  36185. * @param forcedExtension defines the extension to use to pick the right loader
  36186. * @param mimeType defines an optional mime type
  36187. * @returns a InternalTexture for assignment back into BABYLON.Texture
  36188. */
  36189. 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;
  36190. /**
  36191. * Loads an image as an HTMLImageElement.
  36192. * @param input url string, ArrayBuffer, or Blob to load
  36193. * @param onLoad callback called when the image successfully loads
  36194. * @param onError callback called when the image fails to load
  36195. * @param offlineProvider offline provider for caching
  36196. * @param mimeType optional mime type
  36197. * @returns the HTMLImageElement of the loaded image
  36198. * @hidden
  36199. */
  36200. 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>;
  36201. /**
  36202. * @hidden
  36203. */
  36204. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  36205. private _unpackFlipYCached;
  36206. /**
  36207. * In case you are sharing the context with other applications, it might
  36208. * be interested to not cache the unpack flip y state to ensure a consistent
  36209. * value would be set.
  36210. */
  36211. enableUnpackFlipYCached: boolean;
  36212. /** @hidden */
  36213. _unpackFlipY(value: boolean): void;
  36214. /** @hidden */
  36215. _getUnpackAlignement(): number;
  36216. private _getTextureTarget;
  36217. /**
  36218. * Update the sampling mode of a given texture
  36219. * @param samplingMode defines the required sampling mode
  36220. * @param texture defines the texture to update
  36221. * @param generateMipMaps defines whether to generate mipmaps for the texture
  36222. */
  36223. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  36224. /**
  36225. * Update the sampling mode of a given texture
  36226. * @param texture defines the texture to update
  36227. * @param wrapU defines the texture wrap mode of the u coordinates
  36228. * @param wrapV defines the texture wrap mode of the v coordinates
  36229. * @param wrapR defines the texture wrap mode of the r coordinates
  36230. */
  36231. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  36232. /** @hidden */
  36233. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  36234. width: number;
  36235. height: number;
  36236. layers?: number;
  36237. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  36238. /** @hidden */
  36239. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36240. /** @hidden */
  36241. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  36242. /**
  36243. * Update a portion of an internal texture
  36244. * @param texture defines the texture to update
  36245. * @param imageData defines the data to store into the texture
  36246. * @param xOffset defines the x coordinates of the update rectangle
  36247. * @param yOffset defines the y coordinates of the update rectangle
  36248. * @param width defines the width of the update rectangle
  36249. * @param height defines the height of the update rectangle
  36250. * @param faceIndex defines the face index if texture is a cube (0 by default)
  36251. * @param lod defines the lod level to update (0 by default)
  36252. */
  36253. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  36254. /** @hidden */
  36255. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36256. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  36257. private _prepareWebGLTexture;
  36258. /** @hidden */
  36259. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  36260. private _getDepthStencilBuffer;
  36261. /** @hidden */
  36262. _releaseFramebufferObjects(texture: InternalTexture): void;
  36263. /** @hidden */
  36264. _releaseTexture(texture: InternalTexture): void;
  36265. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  36266. protected _setProgram(program: WebGLProgram): void;
  36267. protected _boundUniforms: {
  36268. [key: number]: WebGLUniformLocation;
  36269. };
  36270. /**
  36271. * Binds an effect to the webGL context
  36272. * @param effect defines the effect to bind
  36273. */
  36274. bindSamplers(effect: Effect): void;
  36275. private _activateCurrentTexture;
  36276. /** @hidden */
  36277. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  36278. /** @hidden */
  36279. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  36280. /**
  36281. * Unbind all textures from the webGL context
  36282. */
  36283. unbindAllTextures(): void;
  36284. /**
  36285. * Sets a texture to the according uniform.
  36286. * @param channel The texture channel
  36287. * @param uniform The uniform to set
  36288. * @param texture The texture to apply
  36289. */
  36290. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  36291. private _bindSamplerUniformToChannel;
  36292. private _getTextureWrapMode;
  36293. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  36294. /**
  36295. * Sets an array of texture to the webGL context
  36296. * @param channel defines the channel where the texture array must be set
  36297. * @param uniform defines the associated uniform location
  36298. * @param textures defines the array of textures to bind
  36299. */
  36300. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  36301. /** @hidden */
  36302. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  36303. private _setTextureParameterFloat;
  36304. private _setTextureParameterInteger;
  36305. /**
  36306. * Unbind all vertex attributes from the webGL context
  36307. */
  36308. unbindAllAttributes(): void;
  36309. /**
  36310. * 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
  36311. */
  36312. releaseEffects(): void;
  36313. /**
  36314. * Dispose and release all associated resources
  36315. */
  36316. dispose(): void;
  36317. /**
  36318. * Attach a new callback raised when context lost event is fired
  36319. * @param callback defines the callback to call
  36320. */
  36321. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36322. /**
  36323. * Attach a new callback raised when context restored event is fired
  36324. * @param callback defines the callback to call
  36325. */
  36326. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36327. /**
  36328. * Get the current error code of the webGL context
  36329. * @returns the error code
  36330. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  36331. */
  36332. getError(): number;
  36333. private _canRenderToFloatFramebuffer;
  36334. private _canRenderToHalfFloatFramebuffer;
  36335. private _canRenderToFramebuffer;
  36336. /** @hidden */
  36337. _getWebGLTextureType(type: number): number;
  36338. /** @hidden */
  36339. _getInternalFormat(format: number): number;
  36340. /** @hidden */
  36341. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  36342. /** @hidden */
  36343. _getRGBAMultiSampleBufferFormat(type: number): number;
  36344. /** @hidden */
  36345. _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;
  36346. /**
  36347. * Loads a file from a url
  36348. * @param url url to load
  36349. * @param onSuccess callback called when the file successfully loads
  36350. * @param onProgress callback called while file is loading (if the server supports this mode)
  36351. * @param offlineProvider defines the offline provider for caching
  36352. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  36353. * @param onError callback called when the file fails to load
  36354. * @returns a file request object
  36355. * @hidden
  36356. */
  36357. 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;
  36358. /**
  36359. * Reads pixels from the current frame buffer. Please note that this function can be slow
  36360. * @param x defines the x coordinate of the rectangle where pixels must be read
  36361. * @param y defines the y coordinate of the rectangle where pixels must be read
  36362. * @param width defines the width of the rectangle where pixels must be read
  36363. * @param height defines the height of the rectangle where pixels must be read
  36364. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  36365. * @returns a Uint8Array containing RGBA colors
  36366. */
  36367. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  36368. private static _isSupported;
  36369. /**
  36370. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  36371. * @returns true if the engine can be created
  36372. * @ignorenaming
  36373. */
  36374. static isSupported(): boolean;
  36375. /**
  36376. * Find the next highest power of two.
  36377. * @param x Number to start search from.
  36378. * @return Next highest power of two.
  36379. */
  36380. static CeilingPOT(x: number): number;
  36381. /**
  36382. * Find the next lowest power of two.
  36383. * @param x Number to start search from.
  36384. * @return Next lowest power of two.
  36385. */
  36386. static FloorPOT(x: number): number;
  36387. /**
  36388. * Find the nearest power of two.
  36389. * @param x Number to start search from.
  36390. * @return Next nearest power of two.
  36391. */
  36392. static NearestPOT(x: number): number;
  36393. /**
  36394. * Get the closest exponent of two
  36395. * @param value defines the value to approximate
  36396. * @param max defines the maximum value to return
  36397. * @param mode defines how to define the closest value
  36398. * @returns closest exponent of two of the given value
  36399. */
  36400. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  36401. /**
  36402. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  36403. * @param func - the function to be called
  36404. * @param requester - the object that will request the next frame. Falls back to window.
  36405. * @returns frame number
  36406. */
  36407. static QueueNewFrame(func: () => void, requester?: any): number;
  36408. /**
  36409. * Gets host document
  36410. * @returns the host document object
  36411. */
  36412. getHostDocument(): Nullable<Document>;
  36413. }
  36414. }
  36415. declare module BABYLON {
  36416. /**
  36417. * Class representing spherical harmonics coefficients to the 3rd degree
  36418. */
  36419. export class SphericalHarmonics {
  36420. /**
  36421. * Defines whether or not the harmonics have been prescaled for rendering.
  36422. */
  36423. preScaled: boolean;
  36424. /**
  36425. * The l0,0 coefficients of the spherical harmonics
  36426. */
  36427. l00: Vector3;
  36428. /**
  36429. * The l1,-1 coefficients of the spherical harmonics
  36430. */
  36431. l1_1: Vector3;
  36432. /**
  36433. * The l1,0 coefficients of the spherical harmonics
  36434. */
  36435. l10: Vector3;
  36436. /**
  36437. * The l1,1 coefficients of the spherical harmonics
  36438. */
  36439. l11: Vector3;
  36440. /**
  36441. * The l2,-2 coefficients of the spherical harmonics
  36442. */
  36443. l2_2: Vector3;
  36444. /**
  36445. * The l2,-1 coefficients of the spherical harmonics
  36446. */
  36447. l2_1: Vector3;
  36448. /**
  36449. * The l2,0 coefficients of the spherical harmonics
  36450. */
  36451. l20: Vector3;
  36452. /**
  36453. * The l2,1 coefficients of the spherical harmonics
  36454. */
  36455. l21: Vector3;
  36456. /**
  36457. * The l2,2 coefficients of the spherical harmonics
  36458. */
  36459. l22: Vector3;
  36460. /**
  36461. * Adds a light to the spherical harmonics
  36462. * @param direction the direction of the light
  36463. * @param color the color of the light
  36464. * @param deltaSolidAngle the delta solid angle of the light
  36465. */
  36466. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  36467. /**
  36468. * Scales the spherical harmonics by the given amount
  36469. * @param scale the amount to scale
  36470. */
  36471. scaleInPlace(scale: number): void;
  36472. /**
  36473. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  36474. *
  36475. * ```
  36476. * E_lm = A_l * L_lm
  36477. * ```
  36478. *
  36479. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  36480. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  36481. * the scaling factors are given in equation 9.
  36482. */
  36483. convertIncidentRadianceToIrradiance(): void;
  36484. /**
  36485. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  36486. *
  36487. * ```
  36488. * L = (1/pi) * E * rho
  36489. * ```
  36490. *
  36491. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  36492. */
  36493. convertIrradianceToLambertianRadiance(): void;
  36494. /**
  36495. * Integrates the reconstruction coefficients directly in to the SH preventing further
  36496. * required operations at run time.
  36497. *
  36498. * This is simply done by scaling back the SH with Ylm constants parameter.
  36499. * The trigonometric part being applied by the shader at run time.
  36500. */
  36501. preScaleForRendering(): void;
  36502. /**
  36503. * Constructs a spherical harmonics from an array.
  36504. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  36505. * @returns the spherical harmonics
  36506. */
  36507. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  36508. /**
  36509. * Gets the spherical harmonics from polynomial
  36510. * @param polynomial the spherical polynomial
  36511. * @returns the spherical harmonics
  36512. */
  36513. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  36514. }
  36515. /**
  36516. * Class representing spherical polynomial coefficients to the 3rd degree
  36517. */
  36518. export class SphericalPolynomial {
  36519. private _harmonics;
  36520. /**
  36521. * The spherical harmonics used to create the polynomials.
  36522. */
  36523. get preScaledHarmonics(): SphericalHarmonics;
  36524. /**
  36525. * The x coefficients of the spherical polynomial
  36526. */
  36527. x: Vector3;
  36528. /**
  36529. * The y coefficients of the spherical polynomial
  36530. */
  36531. y: Vector3;
  36532. /**
  36533. * The z coefficients of the spherical polynomial
  36534. */
  36535. z: Vector3;
  36536. /**
  36537. * The xx coefficients of the spherical polynomial
  36538. */
  36539. xx: Vector3;
  36540. /**
  36541. * The yy coefficients of the spherical polynomial
  36542. */
  36543. yy: Vector3;
  36544. /**
  36545. * The zz coefficients of the spherical polynomial
  36546. */
  36547. zz: Vector3;
  36548. /**
  36549. * The xy coefficients of the spherical polynomial
  36550. */
  36551. xy: Vector3;
  36552. /**
  36553. * The yz coefficients of the spherical polynomial
  36554. */
  36555. yz: Vector3;
  36556. /**
  36557. * The zx coefficients of the spherical polynomial
  36558. */
  36559. zx: Vector3;
  36560. /**
  36561. * Adds an ambient color to the spherical polynomial
  36562. * @param color the color to add
  36563. */
  36564. addAmbient(color: Color3): void;
  36565. /**
  36566. * Scales the spherical polynomial by the given amount
  36567. * @param scale the amount to scale
  36568. */
  36569. scaleInPlace(scale: number): void;
  36570. /**
  36571. * Gets the spherical polynomial from harmonics
  36572. * @param harmonics the spherical harmonics
  36573. * @returns the spherical polynomial
  36574. */
  36575. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  36576. /**
  36577. * Constructs a spherical polynomial from an array.
  36578. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  36579. * @returns the spherical polynomial
  36580. */
  36581. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  36582. }
  36583. }
  36584. declare module BABYLON {
  36585. /**
  36586. * Defines the source of the internal texture
  36587. */
  36588. export enum InternalTextureSource {
  36589. /**
  36590. * The source of the texture data is unknown
  36591. */
  36592. Unknown = 0,
  36593. /**
  36594. * Texture data comes from an URL
  36595. */
  36596. Url = 1,
  36597. /**
  36598. * Texture data is only used for temporary storage
  36599. */
  36600. Temp = 2,
  36601. /**
  36602. * Texture data comes from raw data (ArrayBuffer)
  36603. */
  36604. Raw = 3,
  36605. /**
  36606. * Texture content is dynamic (video or dynamic texture)
  36607. */
  36608. Dynamic = 4,
  36609. /**
  36610. * Texture content is generated by rendering to it
  36611. */
  36612. RenderTarget = 5,
  36613. /**
  36614. * Texture content is part of a multi render target process
  36615. */
  36616. MultiRenderTarget = 6,
  36617. /**
  36618. * Texture data comes from a cube data file
  36619. */
  36620. Cube = 7,
  36621. /**
  36622. * Texture data comes from a raw cube data
  36623. */
  36624. CubeRaw = 8,
  36625. /**
  36626. * Texture data come from a prefiltered cube data file
  36627. */
  36628. CubePrefiltered = 9,
  36629. /**
  36630. * Texture content is raw 3D data
  36631. */
  36632. Raw3D = 10,
  36633. /**
  36634. * Texture content is raw 2D array data
  36635. */
  36636. Raw2DArray = 11,
  36637. /**
  36638. * Texture content is a depth texture
  36639. */
  36640. Depth = 12,
  36641. /**
  36642. * Texture data comes from a raw cube data encoded with RGBD
  36643. */
  36644. CubeRawRGBD = 13
  36645. }
  36646. /**
  36647. * Class used to store data associated with WebGL texture data for the engine
  36648. * This class should not be used directly
  36649. */
  36650. export class InternalTexture {
  36651. /** @hidden */
  36652. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  36653. /**
  36654. * Defines if the texture is ready
  36655. */
  36656. isReady: boolean;
  36657. /**
  36658. * Defines if the texture is a cube texture
  36659. */
  36660. isCube: boolean;
  36661. /**
  36662. * Defines if the texture contains 3D data
  36663. */
  36664. is3D: boolean;
  36665. /**
  36666. * Defines if the texture contains 2D array data
  36667. */
  36668. is2DArray: boolean;
  36669. /**
  36670. * Defines if the texture contains multiview data
  36671. */
  36672. isMultiview: boolean;
  36673. /**
  36674. * Gets the URL used to load this texture
  36675. */
  36676. url: string;
  36677. /**
  36678. * Gets the sampling mode of the texture
  36679. */
  36680. samplingMode: number;
  36681. /**
  36682. * Gets a boolean indicating if the texture needs mipmaps generation
  36683. */
  36684. generateMipMaps: boolean;
  36685. /**
  36686. * Gets the number of samples used by the texture (WebGL2+ only)
  36687. */
  36688. samples: number;
  36689. /**
  36690. * Gets the type of the texture (int, float...)
  36691. */
  36692. type: number;
  36693. /**
  36694. * Gets the format of the texture (RGB, RGBA...)
  36695. */
  36696. format: number;
  36697. /**
  36698. * Observable called when the texture is loaded
  36699. */
  36700. onLoadedObservable: Observable<InternalTexture>;
  36701. /**
  36702. * Gets the width of the texture
  36703. */
  36704. width: number;
  36705. /**
  36706. * Gets the height of the texture
  36707. */
  36708. height: number;
  36709. /**
  36710. * Gets the depth of the texture
  36711. */
  36712. depth: number;
  36713. /**
  36714. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  36715. */
  36716. baseWidth: number;
  36717. /**
  36718. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  36719. */
  36720. baseHeight: number;
  36721. /**
  36722. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  36723. */
  36724. baseDepth: number;
  36725. /**
  36726. * Gets a boolean indicating if the texture is inverted on Y axis
  36727. */
  36728. invertY: boolean;
  36729. /** @hidden */
  36730. _invertVScale: boolean;
  36731. /** @hidden */
  36732. _associatedChannel: number;
  36733. /** @hidden */
  36734. _source: InternalTextureSource;
  36735. /** @hidden */
  36736. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  36737. /** @hidden */
  36738. _bufferView: Nullable<ArrayBufferView>;
  36739. /** @hidden */
  36740. _bufferViewArray: Nullable<ArrayBufferView[]>;
  36741. /** @hidden */
  36742. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  36743. /** @hidden */
  36744. _size: number;
  36745. /** @hidden */
  36746. _extension: string;
  36747. /** @hidden */
  36748. _files: Nullable<string[]>;
  36749. /** @hidden */
  36750. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36751. /** @hidden */
  36752. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36753. /** @hidden */
  36754. _framebuffer: Nullable<WebGLFramebuffer>;
  36755. /** @hidden */
  36756. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  36757. /** @hidden */
  36758. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  36759. /** @hidden */
  36760. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  36761. /** @hidden */
  36762. _attachments: Nullable<number[]>;
  36763. /** @hidden */
  36764. _textureArray: Nullable<InternalTexture[]>;
  36765. /** @hidden */
  36766. _cachedCoordinatesMode: Nullable<number>;
  36767. /** @hidden */
  36768. _cachedWrapU: Nullable<number>;
  36769. /** @hidden */
  36770. _cachedWrapV: Nullable<number>;
  36771. /** @hidden */
  36772. _cachedWrapR: Nullable<number>;
  36773. /** @hidden */
  36774. _cachedAnisotropicFilteringLevel: Nullable<number>;
  36775. /** @hidden */
  36776. _isDisabled: boolean;
  36777. /** @hidden */
  36778. _compression: Nullable<string>;
  36779. /** @hidden */
  36780. _generateStencilBuffer: boolean;
  36781. /** @hidden */
  36782. _generateDepthBuffer: boolean;
  36783. /** @hidden */
  36784. _comparisonFunction: number;
  36785. /** @hidden */
  36786. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  36787. /** @hidden */
  36788. _lodGenerationScale: number;
  36789. /** @hidden */
  36790. _lodGenerationOffset: number;
  36791. /** @hidden */
  36792. _depthStencilTexture: Nullable<InternalTexture>;
  36793. /** @hidden */
  36794. _colorTextureArray: Nullable<WebGLTexture>;
  36795. /** @hidden */
  36796. _depthStencilTextureArray: Nullable<WebGLTexture>;
  36797. /** @hidden */
  36798. _lodTextureHigh: Nullable<BaseTexture>;
  36799. /** @hidden */
  36800. _lodTextureMid: Nullable<BaseTexture>;
  36801. /** @hidden */
  36802. _lodTextureLow: Nullable<BaseTexture>;
  36803. /** @hidden */
  36804. _isRGBD: boolean;
  36805. /** @hidden */
  36806. _linearSpecularLOD: boolean;
  36807. /** @hidden */
  36808. _irradianceTexture: Nullable<BaseTexture>;
  36809. /** @hidden */
  36810. _webGLTexture: Nullable<WebGLTexture>;
  36811. /** @hidden */
  36812. _references: number;
  36813. /** @hidden */
  36814. _gammaSpace: Nullable<boolean>;
  36815. private _engine;
  36816. /**
  36817. * Gets the Engine the texture belongs to.
  36818. * @returns The babylon engine
  36819. */
  36820. getEngine(): ThinEngine;
  36821. /**
  36822. * Gets the data source type of the texture
  36823. */
  36824. get source(): InternalTextureSource;
  36825. /**
  36826. * Creates a new InternalTexture
  36827. * @param engine defines the engine to use
  36828. * @param source defines the type of data that will be used
  36829. * @param delayAllocation if the texture allocation should be delayed (default: false)
  36830. */
  36831. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  36832. /**
  36833. * Increments the number of references (ie. the number of Texture that point to it)
  36834. */
  36835. incrementReferences(): void;
  36836. /**
  36837. * Change the size of the texture (not the size of the content)
  36838. * @param width defines the new width
  36839. * @param height defines the new height
  36840. * @param depth defines the new depth (1 by default)
  36841. */
  36842. updateSize(width: int, height: int, depth?: int): void;
  36843. /** @hidden */
  36844. _rebuild(): void;
  36845. /** @hidden */
  36846. _swapAndDie(target: InternalTexture): void;
  36847. /**
  36848. * Dispose the current allocated resources
  36849. */
  36850. dispose(): void;
  36851. }
  36852. }
  36853. declare module BABYLON {
  36854. /**
  36855. * Class used to work with sound analyzer using fast fourier transform (FFT)
  36856. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36857. */
  36858. export class Analyser {
  36859. /**
  36860. * Gets or sets the smoothing
  36861. * @ignorenaming
  36862. */
  36863. SMOOTHING: number;
  36864. /**
  36865. * Gets or sets the FFT table size
  36866. * @ignorenaming
  36867. */
  36868. FFT_SIZE: number;
  36869. /**
  36870. * Gets or sets the bar graph amplitude
  36871. * @ignorenaming
  36872. */
  36873. BARGRAPHAMPLITUDE: number;
  36874. /**
  36875. * Gets or sets the position of the debug canvas
  36876. * @ignorenaming
  36877. */
  36878. DEBUGCANVASPOS: {
  36879. x: number;
  36880. y: number;
  36881. };
  36882. /**
  36883. * Gets or sets the debug canvas size
  36884. * @ignorenaming
  36885. */
  36886. DEBUGCANVASSIZE: {
  36887. width: number;
  36888. height: number;
  36889. };
  36890. private _byteFreqs;
  36891. private _byteTime;
  36892. private _floatFreqs;
  36893. private _webAudioAnalyser;
  36894. private _debugCanvas;
  36895. private _debugCanvasContext;
  36896. private _scene;
  36897. private _registerFunc;
  36898. private _audioEngine;
  36899. /**
  36900. * Creates a new analyser
  36901. * @param scene defines hosting scene
  36902. */
  36903. constructor(scene: Scene);
  36904. /**
  36905. * Get the number of data values you will have to play with for the visualization
  36906. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  36907. * @returns a number
  36908. */
  36909. getFrequencyBinCount(): number;
  36910. /**
  36911. * Gets the current frequency data as a byte array
  36912. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36913. * @returns a Uint8Array
  36914. */
  36915. getByteFrequencyData(): Uint8Array;
  36916. /**
  36917. * Gets the current waveform as a byte array
  36918. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  36919. * @returns a Uint8Array
  36920. */
  36921. getByteTimeDomainData(): Uint8Array;
  36922. /**
  36923. * Gets the current frequency data as a float array
  36924. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36925. * @returns a Float32Array
  36926. */
  36927. getFloatFrequencyData(): Float32Array;
  36928. /**
  36929. * Renders the debug canvas
  36930. */
  36931. drawDebugCanvas(): void;
  36932. /**
  36933. * Stops rendering the debug canvas and removes it
  36934. */
  36935. stopDebugCanvas(): void;
  36936. /**
  36937. * Connects two audio nodes
  36938. * @param inputAudioNode defines first node to connect
  36939. * @param outputAudioNode defines second node to connect
  36940. */
  36941. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  36942. /**
  36943. * Releases all associated resources
  36944. */
  36945. dispose(): void;
  36946. }
  36947. }
  36948. declare module BABYLON {
  36949. /**
  36950. * This represents an audio engine and it is responsible
  36951. * to play, synchronize and analyse sounds throughout the application.
  36952. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36953. */
  36954. export interface IAudioEngine extends IDisposable {
  36955. /**
  36956. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36957. */
  36958. readonly canUseWebAudio: boolean;
  36959. /**
  36960. * Gets the current AudioContext if available.
  36961. */
  36962. readonly audioContext: Nullable<AudioContext>;
  36963. /**
  36964. * The master gain node defines the global audio volume of your audio engine.
  36965. */
  36966. readonly masterGain: GainNode;
  36967. /**
  36968. * Gets whether or not mp3 are supported by your browser.
  36969. */
  36970. readonly isMP3supported: boolean;
  36971. /**
  36972. * Gets whether or not ogg are supported by your browser.
  36973. */
  36974. readonly isOGGsupported: boolean;
  36975. /**
  36976. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36977. * @ignoreNaming
  36978. */
  36979. WarnedWebAudioUnsupported: boolean;
  36980. /**
  36981. * Defines if the audio engine relies on a custom unlocked button.
  36982. * In this case, the embedded button will not be displayed.
  36983. */
  36984. useCustomUnlockedButton: boolean;
  36985. /**
  36986. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  36987. */
  36988. readonly unlocked: boolean;
  36989. /**
  36990. * Event raised when audio has been unlocked on the browser.
  36991. */
  36992. onAudioUnlockedObservable: Observable<AudioEngine>;
  36993. /**
  36994. * Event raised when audio has been locked on the browser.
  36995. */
  36996. onAudioLockedObservable: Observable<AudioEngine>;
  36997. /**
  36998. * Flags the audio engine in Locked state.
  36999. * This happens due to new browser policies preventing audio to autoplay.
  37000. */
  37001. lock(): void;
  37002. /**
  37003. * Unlocks the audio engine once a user action has been done on the dom.
  37004. * This is helpful to resume play once browser policies have been satisfied.
  37005. */
  37006. unlock(): void;
  37007. /**
  37008. * Gets the global volume sets on the master gain.
  37009. * @returns the global volume if set or -1 otherwise
  37010. */
  37011. getGlobalVolume(): number;
  37012. /**
  37013. * Sets the global volume of your experience (sets on the master gain).
  37014. * @param newVolume Defines the new global volume of the application
  37015. */
  37016. setGlobalVolume(newVolume: number): void;
  37017. /**
  37018. * Connect the audio engine to an audio analyser allowing some amazing
  37019. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37020. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37021. * @param analyser The analyser to connect to the engine
  37022. */
  37023. connectToAnalyser(analyser: Analyser): void;
  37024. }
  37025. /**
  37026. * This represents the default audio engine used in babylon.
  37027. * It is responsible to play, synchronize and analyse sounds throughout the application.
  37028. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37029. */
  37030. export class AudioEngine implements IAudioEngine {
  37031. private _audioContext;
  37032. private _audioContextInitialized;
  37033. private _muteButton;
  37034. private _hostElement;
  37035. /**
  37036. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  37037. */
  37038. canUseWebAudio: boolean;
  37039. /**
  37040. * The master gain node defines the global audio volume of your audio engine.
  37041. */
  37042. masterGain: GainNode;
  37043. /**
  37044. * Defines if Babylon should emit a warning if WebAudio is not supported.
  37045. * @ignoreNaming
  37046. */
  37047. WarnedWebAudioUnsupported: boolean;
  37048. /**
  37049. * Gets whether or not mp3 are supported by your browser.
  37050. */
  37051. isMP3supported: boolean;
  37052. /**
  37053. * Gets whether or not ogg are supported by your browser.
  37054. */
  37055. isOGGsupported: boolean;
  37056. /**
  37057. * Gets whether audio has been unlocked on the device.
  37058. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  37059. * a user interaction has happened.
  37060. */
  37061. unlocked: boolean;
  37062. /**
  37063. * Defines if the audio engine relies on a custom unlocked button.
  37064. * In this case, the embedded button will not be displayed.
  37065. */
  37066. useCustomUnlockedButton: boolean;
  37067. /**
  37068. * Event raised when audio has been unlocked on the browser.
  37069. */
  37070. onAudioUnlockedObservable: Observable<AudioEngine>;
  37071. /**
  37072. * Event raised when audio has been locked on the browser.
  37073. */
  37074. onAudioLockedObservable: Observable<AudioEngine>;
  37075. /**
  37076. * Gets the current AudioContext if available.
  37077. */
  37078. get audioContext(): Nullable<AudioContext>;
  37079. private _connectedAnalyser;
  37080. /**
  37081. * Instantiates a new audio engine.
  37082. *
  37083. * There should be only one per page as some browsers restrict the number
  37084. * of audio contexts you can create.
  37085. * @param hostElement defines the host element where to display the mute icon if necessary
  37086. */
  37087. constructor(hostElement?: Nullable<HTMLElement>);
  37088. /**
  37089. * Flags the audio engine in Locked state.
  37090. * This happens due to new browser policies preventing audio to autoplay.
  37091. */
  37092. lock(): void;
  37093. /**
  37094. * Unlocks the audio engine once a user action has been done on the dom.
  37095. * This is helpful to resume play once browser policies have been satisfied.
  37096. */
  37097. unlock(): void;
  37098. private _resumeAudioContext;
  37099. private _initializeAudioContext;
  37100. private _tryToRun;
  37101. private _triggerRunningState;
  37102. private _triggerSuspendedState;
  37103. private _displayMuteButton;
  37104. private _moveButtonToTopLeft;
  37105. private _onResize;
  37106. private _hideMuteButton;
  37107. /**
  37108. * Destroy and release the resources associated with the audio ccontext.
  37109. */
  37110. dispose(): void;
  37111. /**
  37112. * Gets the global volume sets on the master gain.
  37113. * @returns the global volume if set or -1 otherwise
  37114. */
  37115. getGlobalVolume(): number;
  37116. /**
  37117. * Sets the global volume of your experience (sets on the master gain).
  37118. * @param newVolume Defines the new global volume of the application
  37119. */
  37120. setGlobalVolume(newVolume: number): void;
  37121. /**
  37122. * Connect the audio engine to an audio analyser allowing some amazing
  37123. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37124. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37125. * @param analyser The analyser to connect to the engine
  37126. */
  37127. connectToAnalyser(analyser: Analyser): void;
  37128. }
  37129. }
  37130. declare module BABYLON {
  37131. /**
  37132. * Interface used to present a loading screen while loading a scene
  37133. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37134. */
  37135. export interface ILoadingScreen {
  37136. /**
  37137. * Function called to display the loading screen
  37138. */
  37139. displayLoadingUI: () => void;
  37140. /**
  37141. * Function called to hide the loading screen
  37142. */
  37143. hideLoadingUI: () => void;
  37144. /**
  37145. * Gets or sets the color to use for the background
  37146. */
  37147. loadingUIBackgroundColor: string;
  37148. /**
  37149. * Gets or sets the text to display while loading
  37150. */
  37151. loadingUIText: string;
  37152. }
  37153. /**
  37154. * Class used for the default loading screen
  37155. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37156. */
  37157. export class DefaultLoadingScreen implements ILoadingScreen {
  37158. private _renderingCanvas;
  37159. private _loadingText;
  37160. private _loadingDivBackgroundColor;
  37161. private _loadingDiv;
  37162. private _loadingTextDiv;
  37163. /** Gets or sets the logo url to use for the default loading screen */
  37164. static DefaultLogoUrl: string;
  37165. /** Gets or sets the spinner url to use for the default loading screen */
  37166. static DefaultSpinnerUrl: string;
  37167. /**
  37168. * Creates a new default loading screen
  37169. * @param _renderingCanvas defines the canvas used to render the scene
  37170. * @param _loadingText defines the default text to display
  37171. * @param _loadingDivBackgroundColor defines the default background color
  37172. */
  37173. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  37174. /**
  37175. * Function called to display the loading screen
  37176. */
  37177. displayLoadingUI(): void;
  37178. /**
  37179. * Function called to hide the loading screen
  37180. */
  37181. hideLoadingUI(): void;
  37182. /**
  37183. * Gets or sets the text to display while loading
  37184. */
  37185. set loadingUIText(text: string);
  37186. get loadingUIText(): string;
  37187. /**
  37188. * Gets or sets the color to use for the background
  37189. */
  37190. get loadingUIBackgroundColor(): string;
  37191. set loadingUIBackgroundColor(color: string);
  37192. private _resizeLoadingUI;
  37193. }
  37194. }
  37195. declare module BABYLON {
  37196. /**
  37197. * Interface for any object that can request an animation frame
  37198. */
  37199. export interface ICustomAnimationFrameRequester {
  37200. /**
  37201. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  37202. */
  37203. renderFunction?: Function;
  37204. /**
  37205. * Called to request the next frame to render to
  37206. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  37207. */
  37208. requestAnimationFrame: Function;
  37209. /**
  37210. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  37211. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  37212. */
  37213. requestID?: number;
  37214. }
  37215. }
  37216. declare module BABYLON {
  37217. /**
  37218. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  37219. */
  37220. export class PerformanceMonitor {
  37221. private _enabled;
  37222. private _rollingFrameTime;
  37223. private _lastFrameTimeMs;
  37224. /**
  37225. * constructor
  37226. * @param frameSampleSize The number of samples required to saturate the sliding window
  37227. */
  37228. constructor(frameSampleSize?: number);
  37229. /**
  37230. * Samples current frame
  37231. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  37232. */
  37233. sampleFrame(timeMs?: number): void;
  37234. /**
  37235. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37236. */
  37237. get averageFrameTime(): number;
  37238. /**
  37239. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37240. */
  37241. get averageFrameTimeVariance(): number;
  37242. /**
  37243. * Returns the frame time of the most recent frame
  37244. */
  37245. get instantaneousFrameTime(): number;
  37246. /**
  37247. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  37248. */
  37249. get averageFPS(): number;
  37250. /**
  37251. * Returns the average framerate in frames per second using the most recent frame time
  37252. */
  37253. get instantaneousFPS(): number;
  37254. /**
  37255. * Returns true if enough samples have been taken to completely fill the sliding window
  37256. */
  37257. get isSaturated(): boolean;
  37258. /**
  37259. * Enables contributions to the sliding window sample set
  37260. */
  37261. enable(): void;
  37262. /**
  37263. * Disables contributions to the sliding window sample set
  37264. * Samples will not be interpolated over the disabled period
  37265. */
  37266. disable(): void;
  37267. /**
  37268. * Returns true if sampling is enabled
  37269. */
  37270. get isEnabled(): boolean;
  37271. /**
  37272. * Resets performance monitor
  37273. */
  37274. reset(): void;
  37275. }
  37276. /**
  37277. * RollingAverage
  37278. *
  37279. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  37280. */
  37281. export class RollingAverage {
  37282. /**
  37283. * Current average
  37284. */
  37285. average: number;
  37286. /**
  37287. * Current variance
  37288. */
  37289. variance: number;
  37290. protected _samples: Array<number>;
  37291. protected _sampleCount: number;
  37292. protected _pos: number;
  37293. protected _m2: number;
  37294. /**
  37295. * constructor
  37296. * @param length The number of samples required to saturate the sliding window
  37297. */
  37298. constructor(length: number);
  37299. /**
  37300. * Adds a sample to the sample set
  37301. * @param v The sample value
  37302. */
  37303. add(v: number): void;
  37304. /**
  37305. * Returns previously added values or null if outside of history or outside the sliding window domain
  37306. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  37307. * @return Value previously recorded with add() or null if outside of range
  37308. */
  37309. history(i: number): number;
  37310. /**
  37311. * Returns true if enough samples have been taken to completely fill the sliding window
  37312. * @return true if sample-set saturated
  37313. */
  37314. isSaturated(): boolean;
  37315. /**
  37316. * Resets the rolling average (equivalent to 0 samples taken so far)
  37317. */
  37318. reset(): void;
  37319. /**
  37320. * Wraps a value around the sample range boundaries
  37321. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  37322. * @return Wrapped position in sample range
  37323. */
  37324. protected _wrapPosition(i: number): number;
  37325. }
  37326. }
  37327. declare module BABYLON {
  37328. /**
  37329. * This class is used to track a performance counter which is number based.
  37330. * The user has access to many properties which give statistics of different nature.
  37331. *
  37332. * The implementer can track two kinds of Performance Counter: time and count.
  37333. * 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.
  37334. * 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.
  37335. */
  37336. export class PerfCounter {
  37337. /**
  37338. * Gets or sets a global boolean to turn on and off all the counters
  37339. */
  37340. static Enabled: boolean;
  37341. /**
  37342. * Returns the smallest value ever
  37343. */
  37344. get min(): number;
  37345. /**
  37346. * Returns the biggest value ever
  37347. */
  37348. get max(): number;
  37349. /**
  37350. * Returns the average value since the performance counter is running
  37351. */
  37352. get average(): number;
  37353. /**
  37354. * Returns the average value of the last second the counter was monitored
  37355. */
  37356. get lastSecAverage(): number;
  37357. /**
  37358. * Returns the current value
  37359. */
  37360. get current(): number;
  37361. /**
  37362. * Gets the accumulated total
  37363. */
  37364. get total(): number;
  37365. /**
  37366. * Gets the total value count
  37367. */
  37368. get count(): number;
  37369. /**
  37370. * Creates a new counter
  37371. */
  37372. constructor();
  37373. /**
  37374. * Call this method to start monitoring a new frame.
  37375. * 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.
  37376. */
  37377. fetchNewFrame(): void;
  37378. /**
  37379. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  37380. * @param newCount the count value to add to the monitored count
  37381. * @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.
  37382. */
  37383. addCount(newCount: number, fetchResult: boolean): void;
  37384. /**
  37385. * Start monitoring this performance counter
  37386. */
  37387. beginMonitoring(): void;
  37388. /**
  37389. * Compute the time lapsed since the previous beginMonitoring() call.
  37390. * @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
  37391. */
  37392. endMonitoring(newFrame?: boolean): void;
  37393. private _fetchResult;
  37394. private _startMonitoringTime;
  37395. private _min;
  37396. private _max;
  37397. private _average;
  37398. private _current;
  37399. private _totalValueCount;
  37400. private _totalAccumulated;
  37401. private _lastSecAverage;
  37402. private _lastSecAccumulated;
  37403. private _lastSecTime;
  37404. private _lastSecValueCount;
  37405. }
  37406. }
  37407. declare module BABYLON {
  37408. interface ThinEngine {
  37409. /** @hidden */
  37410. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  37411. }
  37412. }
  37413. declare module BABYLON {
  37414. /**
  37415. * Defines the interface used by display changed events
  37416. */
  37417. export interface IDisplayChangedEventArgs {
  37418. /** Gets the vrDisplay object (if any) */
  37419. vrDisplay: Nullable<any>;
  37420. /** Gets a boolean indicating if webVR is supported */
  37421. vrSupported: boolean;
  37422. }
  37423. /**
  37424. * Defines the interface used by objects containing a viewport (like a camera)
  37425. */
  37426. interface IViewportOwnerLike {
  37427. /**
  37428. * Gets or sets the viewport
  37429. */
  37430. viewport: IViewportLike;
  37431. }
  37432. /**
  37433. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  37434. */
  37435. export class Engine extends ThinEngine {
  37436. /** Defines that alpha blending is disabled */
  37437. static readonly ALPHA_DISABLE: number;
  37438. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  37439. static readonly ALPHA_ADD: number;
  37440. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  37441. static readonly ALPHA_COMBINE: number;
  37442. /** Defines that alpha blending to DEST - SRC * DEST */
  37443. static readonly ALPHA_SUBTRACT: number;
  37444. /** Defines that alpha blending to SRC * DEST */
  37445. static readonly ALPHA_MULTIPLY: number;
  37446. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  37447. static readonly ALPHA_MAXIMIZED: number;
  37448. /** Defines that alpha blending to SRC + DEST */
  37449. static readonly ALPHA_ONEONE: number;
  37450. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  37451. static readonly ALPHA_PREMULTIPLIED: number;
  37452. /**
  37453. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  37454. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  37455. */
  37456. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  37457. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  37458. static readonly ALPHA_INTERPOLATE: number;
  37459. /**
  37460. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  37461. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  37462. */
  37463. static readonly ALPHA_SCREENMODE: number;
  37464. /** Defines that the ressource is not delayed*/
  37465. static readonly DELAYLOADSTATE_NONE: number;
  37466. /** Defines that the ressource was successfully delay loaded */
  37467. static readonly DELAYLOADSTATE_LOADED: number;
  37468. /** Defines that the ressource is currently delay loading */
  37469. static readonly DELAYLOADSTATE_LOADING: number;
  37470. /** Defines that the ressource is delayed and has not started loading */
  37471. static readonly DELAYLOADSTATE_NOTLOADED: number;
  37472. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  37473. static readonly NEVER: number;
  37474. /** 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 */
  37475. static readonly ALWAYS: number;
  37476. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  37477. static readonly LESS: number;
  37478. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  37479. static readonly EQUAL: number;
  37480. /** 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 */
  37481. static readonly LEQUAL: number;
  37482. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  37483. static readonly GREATER: number;
  37484. /** 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 */
  37485. static readonly GEQUAL: number;
  37486. /** 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 */
  37487. static readonly NOTEQUAL: number;
  37488. /** Passed to stencilOperation to specify that stencil value must be kept */
  37489. static readonly KEEP: number;
  37490. /** Passed to stencilOperation to specify that stencil value must be replaced */
  37491. static readonly REPLACE: number;
  37492. /** Passed to stencilOperation to specify that stencil value must be incremented */
  37493. static readonly INCR: number;
  37494. /** Passed to stencilOperation to specify that stencil value must be decremented */
  37495. static readonly DECR: number;
  37496. /** Passed to stencilOperation to specify that stencil value must be inverted */
  37497. static readonly INVERT: number;
  37498. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  37499. static readonly INCR_WRAP: number;
  37500. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  37501. static readonly DECR_WRAP: number;
  37502. /** Texture is not repeating outside of 0..1 UVs */
  37503. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  37504. /** Texture is repeating outside of 0..1 UVs */
  37505. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  37506. /** Texture is repeating and mirrored */
  37507. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  37508. /** ALPHA */
  37509. static readonly TEXTUREFORMAT_ALPHA: number;
  37510. /** LUMINANCE */
  37511. static readonly TEXTUREFORMAT_LUMINANCE: number;
  37512. /** LUMINANCE_ALPHA */
  37513. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  37514. /** RGB */
  37515. static readonly TEXTUREFORMAT_RGB: number;
  37516. /** RGBA */
  37517. static readonly TEXTUREFORMAT_RGBA: number;
  37518. /** RED */
  37519. static readonly TEXTUREFORMAT_RED: number;
  37520. /** RED (2nd reference) */
  37521. static readonly TEXTUREFORMAT_R: number;
  37522. /** RG */
  37523. static readonly TEXTUREFORMAT_RG: number;
  37524. /** RED_INTEGER */
  37525. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  37526. /** RED_INTEGER (2nd reference) */
  37527. static readonly TEXTUREFORMAT_R_INTEGER: number;
  37528. /** RG_INTEGER */
  37529. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  37530. /** RGB_INTEGER */
  37531. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  37532. /** RGBA_INTEGER */
  37533. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  37534. /** UNSIGNED_BYTE */
  37535. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  37536. /** UNSIGNED_BYTE (2nd reference) */
  37537. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  37538. /** FLOAT */
  37539. static readonly TEXTURETYPE_FLOAT: number;
  37540. /** HALF_FLOAT */
  37541. static readonly TEXTURETYPE_HALF_FLOAT: number;
  37542. /** BYTE */
  37543. static readonly TEXTURETYPE_BYTE: number;
  37544. /** SHORT */
  37545. static readonly TEXTURETYPE_SHORT: number;
  37546. /** UNSIGNED_SHORT */
  37547. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  37548. /** INT */
  37549. static readonly TEXTURETYPE_INT: number;
  37550. /** UNSIGNED_INT */
  37551. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  37552. /** UNSIGNED_SHORT_4_4_4_4 */
  37553. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  37554. /** UNSIGNED_SHORT_5_5_5_1 */
  37555. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  37556. /** UNSIGNED_SHORT_5_6_5 */
  37557. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  37558. /** UNSIGNED_INT_2_10_10_10_REV */
  37559. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  37560. /** UNSIGNED_INT_24_8 */
  37561. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  37562. /** UNSIGNED_INT_10F_11F_11F_REV */
  37563. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  37564. /** UNSIGNED_INT_5_9_9_9_REV */
  37565. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  37566. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  37567. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  37568. /** nearest is mag = nearest and min = nearest and mip = linear */
  37569. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  37570. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37571. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  37572. /** Trilinear is mag = linear and min = linear and mip = linear */
  37573. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  37574. /** nearest is mag = nearest and min = nearest and mip = linear */
  37575. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  37576. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37577. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  37578. /** Trilinear is mag = linear and min = linear and mip = linear */
  37579. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  37580. /** mag = nearest and min = nearest and mip = nearest */
  37581. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  37582. /** mag = nearest and min = linear and mip = nearest */
  37583. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  37584. /** mag = nearest and min = linear and mip = linear */
  37585. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  37586. /** mag = nearest and min = linear and mip = none */
  37587. static readonly TEXTURE_NEAREST_LINEAR: number;
  37588. /** mag = nearest and min = nearest and mip = none */
  37589. static readonly TEXTURE_NEAREST_NEAREST: number;
  37590. /** mag = linear and min = nearest and mip = nearest */
  37591. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  37592. /** mag = linear and min = nearest and mip = linear */
  37593. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  37594. /** mag = linear and min = linear and mip = none */
  37595. static readonly TEXTURE_LINEAR_LINEAR: number;
  37596. /** mag = linear and min = nearest and mip = none */
  37597. static readonly TEXTURE_LINEAR_NEAREST: number;
  37598. /** Explicit coordinates mode */
  37599. static readonly TEXTURE_EXPLICIT_MODE: number;
  37600. /** Spherical coordinates mode */
  37601. static readonly TEXTURE_SPHERICAL_MODE: number;
  37602. /** Planar coordinates mode */
  37603. static readonly TEXTURE_PLANAR_MODE: number;
  37604. /** Cubic coordinates mode */
  37605. static readonly TEXTURE_CUBIC_MODE: number;
  37606. /** Projection coordinates mode */
  37607. static readonly TEXTURE_PROJECTION_MODE: number;
  37608. /** Skybox coordinates mode */
  37609. static readonly TEXTURE_SKYBOX_MODE: number;
  37610. /** Inverse Cubic coordinates mode */
  37611. static readonly TEXTURE_INVCUBIC_MODE: number;
  37612. /** Equirectangular coordinates mode */
  37613. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  37614. /** Equirectangular Fixed coordinates mode */
  37615. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  37616. /** Equirectangular Fixed Mirrored coordinates mode */
  37617. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  37618. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  37619. static readonly SCALEMODE_FLOOR: number;
  37620. /** Defines that texture rescaling will look for the nearest power of 2 size */
  37621. static readonly SCALEMODE_NEAREST: number;
  37622. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  37623. static readonly SCALEMODE_CEILING: number;
  37624. /**
  37625. * Returns the current npm package of the sdk
  37626. */
  37627. static get NpmPackage(): string;
  37628. /**
  37629. * Returns the current version of the framework
  37630. */
  37631. static get Version(): string;
  37632. /** Gets the list of created engines */
  37633. static get Instances(): Engine[];
  37634. /**
  37635. * Gets the latest created engine
  37636. */
  37637. static get LastCreatedEngine(): Nullable<Engine>;
  37638. /**
  37639. * Gets the latest created scene
  37640. */
  37641. static get LastCreatedScene(): Nullable<Scene>;
  37642. /**
  37643. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  37644. * @param flag defines which part of the materials must be marked as dirty
  37645. * @param predicate defines a predicate used to filter which materials should be affected
  37646. */
  37647. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37648. /**
  37649. * Method called to create the default loading screen.
  37650. * This can be overriden in your own app.
  37651. * @param canvas The rendering canvas element
  37652. * @returns The loading screen
  37653. */
  37654. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  37655. /**
  37656. * Method called to create the default rescale post process on each engine.
  37657. */
  37658. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  37659. /**
  37660. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  37661. **/
  37662. enableOfflineSupport: boolean;
  37663. /**
  37664. * 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)
  37665. **/
  37666. disableManifestCheck: boolean;
  37667. /**
  37668. * Gets the list of created scenes
  37669. */
  37670. scenes: Scene[];
  37671. /**
  37672. * Event raised when a new scene is created
  37673. */
  37674. onNewSceneAddedObservable: Observable<Scene>;
  37675. /**
  37676. * Gets the list of created postprocesses
  37677. */
  37678. postProcesses: PostProcess[];
  37679. /**
  37680. * Gets a boolean indicating if the pointer is currently locked
  37681. */
  37682. isPointerLock: boolean;
  37683. /**
  37684. * Observable event triggered each time the rendering canvas is resized
  37685. */
  37686. onResizeObservable: Observable<Engine>;
  37687. /**
  37688. * Observable event triggered each time the canvas loses focus
  37689. */
  37690. onCanvasBlurObservable: Observable<Engine>;
  37691. /**
  37692. * Observable event triggered each time the canvas gains focus
  37693. */
  37694. onCanvasFocusObservable: Observable<Engine>;
  37695. /**
  37696. * Observable event triggered each time the canvas receives pointerout event
  37697. */
  37698. onCanvasPointerOutObservable: Observable<PointerEvent>;
  37699. /**
  37700. * Observable raised when the engine begins a new frame
  37701. */
  37702. onBeginFrameObservable: Observable<Engine>;
  37703. /**
  37704. * If set, will be used to request the next animation frame for the render loop
  37705. */
  37706. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  37707. /**
  37708. * Observable raised when the engine ends the current frame
  37709. */
  37710. onEndFrameObservable: Observable<Engine>;
  37711. /**
  37712. * Observable raised when the engine is about to compile a shader
  37713. */
  37714. onBeforeShaderCompilationObservable: Observable<Engine>;
  37715. /**
  37716. * Observable raised when the engine has jsut compiled a shader
  37717. */
  37718. onAfterShaderCompilationObservable: Observable<Engine>;
  37719. /**
  37720. * Gets the audio engine
  37721. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37722. * @ignorenaming
  37723. */
  37724. static audioEngine: IAudioEngine;
  37725. /**
  37726. * Default AudioEngine factory responsible of creating the Audio Engine.
  37727. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  37728. */
  37729. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  37730. /**
  37731. * Default offline support factory responsible of creating a tool used to store data locally.
  37732. * By default, this will create a Database object if the workload has been embedded.
  37733. */
  37734. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  37735. private _loadingScreen;
  37736. private _pointerLockRequested;
  37737. private _rescalePostProcess;
  37738. private _deterministicLockstep;
  37739. private _lockstepMaxSteps;
  37740. private _timeStep;
  37741. protected get _supportsHardwareTextureRescaling(): boolean;
  37742. private _fps;
  37743. private _deltaTime;
  37744. /** @hidden */
  37745. _drawCalls: PerfCounter;
  37746. /** 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 */
  37747. canvasTabIndex: number;
  37748. /**
  37749. * Turn this value on if you want to pause FPS computation when in background
  37750. */
  37751. disablePerformanceMonitorInBackground: boolean;
  37752. private _performanceMonitor;
  37753. /**
  37754. * Gets the performance monitor attached to this engine
  37755. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  37756. */
  37757. get performanceMonitor(): PerformanceMonitor;
  37758. private _onFocus;
  37759. private _onBlur;
  37760. private _onCanvasPointerOut;
  37761. private _onCanvasBlur;
  37762. private _onCanvasFocus;
  37763. private _onFullscreenChange;
  37764. private _onPointerLockChange;
  37765. /**
  37766. * Gets the HTML element used to attach event listeners
  37767. * @returns a HTML element
  37768. */
  37769. getInputElement(): Nullable<HTMLElement>;
  37770. /**
  37771. * Creates a new engine
  37772. * @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
  37773. * @param antialias defines enable antialiasing (default: false)
  37774. * @param options defines further options to be sent to the getContext() function
  37775. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  37776. */
  37777. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  37778. /**
  37779. * Gets current aspect ratio
  37780. * @param viewportOwner defines the camera to use to get the aspect ratio
  37781. * @param useScreen defines if screen size must be used (or the current render target if any)
  37782. * @returns a number defining the aspect ratio
  37783. */
  37784. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  37785. /**
  37786. * Gets current screen aspect ratio
  37787. * @returns a number defining the aspect ratio
  37788. */
  37789. getScreenAspectRatio(): number;
  37790. /**
  37791. * Gets the client rect of the HTML canvas attached with the current webGL context
  37792. * @returns a client rectanglee
  37793. */
  37794. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  37795. /**
  37796. * Gets the client rect of the HTML element used for events
  37797. * @returns a client rectanglee
  37798. */
  37799. getInputElementClientRect(): Nullable<ClientRect>;
  37800. /**
  37801. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  37802. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37803. * @returns true if engine is in deterministic lock step mode
  37804. */
  37805. isDeterministicLockStep(): boolean;
  37806. /**
  37807. * Gets the max steps when engine is running in deterministic lock step
  37808. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37809. * @returns the max steps
  37810. */
  37811. getLockstepMaxSteps(): number;
  37812. /**
  37813. * Returns the time in ms between steps when using deterministic lock step.
  37814. * @returns time step in (ms)
  37815. */
  37816. getTimeStep(): number;
  37817. /**
  37818. * Force the mipmap generation for the given render target texture
  37819. * @param texture defines the render target texture to use
  37820. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  37821. */
  37822. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  37823. /** States */
  37824. /**
  37825. * Set various states to the webGL context
  37826. * @param culling defines backface culling state
  37827. * @param zOffset defines the value to apply to zOffset (0 by default)
  37828. * @param force defines if states must be applied even if cache is up to date
  37829. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  37830. */
  37831. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  37832. /**
  37833. * Set the z offset to apply to current rendering
  37834. * @param value defines the offset to apply
  37835. */
  37836. setZOffset(value: number): void;
  37837. /**
  37838. * Gets the current value of the zOffset
  37839. * @returns the current zOffset state
  37840. */
  37841. getZOffset(): number;
  37842. /**
  37843. * Enable or disable depth buffering
  37844. * @param enable defines the state to set
  37845. */
  37846. setDepthBuffer(enable: boolean): void;
  37847. /**
  37848. * Gets a boolean indicating if depth writing is enabled
  37849. * @returns the current depth writing state
  37850. */
  37851. getDepthWrite(): boolean;
  37852. /**
  37853. * Enable or disable depth writing
  37854. * @param enable defines the state to set
  37855. */
  37856. setDepthWrite(enable: boolean): void;
  37857. /**
  37858. * Gets a boolean indicating if stencil buffer is enabled
  37859. * @returns the current stencil buffer state
  37860. */
  37861. getStencilBuffer(): boolean;
  37862. /**
  37863. * Enable or disable the stencil buffer
  37864. * @param enable defines if the stencil buffer must be enabled or disabled
  37865. */
  37866. setStencilBuffer(enable: boolean): void;
  37867. /**
  37868. * Gets the current stencil mask
  37869. * @returns a number defining the new stencil mask to use
  37870. */
  37871. getStencilMask(): number;
  37872. /**
  37873. * Sets the current stencil mask
  37874. * @param mask defines the new stencil mask to use
  37875. */
  37876. setStencilMask(mask: number): void;
  37877. /**
  37878. * Gets the current stencil function
  37879. * @returns a number defining the stencil function to use
  37880. */
  37881. getStencilFunction(): number;
  37882. /**
  37883. * Gets the current stencil reference value
  37884. * @returns a number defining the stencil reference value to use
  37885. */
  37886. getStencilFunctionReference(): number;
  37887. /**
  37888. * Gets the current stencil mask
  37889. * @returns a number defining the stencil mask to use
  37890. */
  37891. getStencilFunctionMask(): number;
  37892. /**
  37893. * Sets the current stencil function
  37894. * @param stencilFunc defines the new stencil function to use
  37895. */
  37896. setStencilFunction(stencilFunc: number): void;
  37897. /**
  37898. * Sets the current stencil reference
  37899. * @param reference defines the new stencil reference to use
  37900. */
  37901. setStencilFunctionReference(reference: number): void;
  37902. /**
  37903. * Sets the current stencil mask
  37904. * @param mask defines the new stencil mask to use
  37905. */
  37906. setStencilFunctionMask(mask: number): void;
  37907. /**
  37908. * Gets the current stencil operation when stencil fails
  37909. * @returns a number defining stencil operation to use when stencil fails
  37910. */
  37911. getStencilOperationFail(): number;
  37912. /**
  37913. * Gets the current stencil operation when depth fails
  37914. * @returns a number defining stencil operation to use when depth fails
  37915. */
  37916. getStencilOperationDepthFail(): number;
  37917. /**
  37918. * Gets the current stencil operation when stencil passes
  37919. * @returns a number defining stencil operation to use when stencil passes
  37920. */
  37921. getStencilOperationPass(): number;
  37922. /**
  37923. * Sets the stencil operation to use when stencil fails
  37924. * @param operation defines the stencil operation to use when stencil fails
  37925. */
  37926. setStencilOperationFail(operation: number): void;
  37927. /**
  37928. * Sets the stencil operation to use when depth fails
  37929. * @param operation defines the stencil operation to use when depth fails
  37930. */
  37931. setStencilOperationDepthFail(operation: number): void;
  37932. /**
  37933. * Sets the stencil operation to use when stencil passes
  37934. * @param operation defines the stencil operation to use when stencil passes
  37935. */
  37936. setStencilOperationPass(operation: number): void;
  37937. /**
  37938. * Sets a boolean indicating if the dithering state is enabled or disabled
  37939. * @param value defines the dithering state
  37940. */
  37941. setDitheringState(value: boolean): void;
  37942. /**
  37943. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  37944. * @param value defines the rasterizer state
  37945. */
  37946. setRasterizerState(value: boolean): void;
  37947. /**
  37948. * Gets the current depth function
  37949. * @returns a number defining the depth function
  37950. */
  37951. getDepthFunction(): Nullable<number>;
  37952. /**
  37953. * Sets the current depth function
  37954. * @param depthFunc defines the function to use
  37955. */
  37956. setDepthFunction(depthFunc: number): void;
  37957. /**
  37958. * Sets the current depth function to GREATER
  37959. */
  37960. setDepthFunctionToGreater(): void;
  37961. /**
  37962. * Sets the current depth function to GEQUAL
  37963. */
  37964. setDepthFunctionToGreaterOrEqual(): void;
  37965. /**
  37966. * Sets the current depth function to LESS
  37967. */
  37968. setDepthFunctionToLess(): void;
  37969. /**
  37970. * Sets the current depth function to LEQUAL
  37971. */
  37972. setDepthFunctionToLessOrEqual(): void;
  37973. private _cachedStencilBuffer;
  37974. private _cachedStencilFunction;
  37975. private _cachedStencilMask;
  37976. private _cachedStencilOperationPass;
  37977. private _cachedStencilOperationFail;
  37978. private _cachedStencilOperationDepthFail;
  37979. private _cachedStencilReference;
  37980. /**
  37981. * Caches the the state of the stencil buffer
  37982. */
  37983. cacheStencilState(): void;
  37984. /**
  37985. * Restores the state of the stencil buffer
  37986. */
  37987. restoreStencilState(): void;
  37988. /**
  37989. * Directly set the WebGL Viewport
  37990. * @param x defines the x coordinate of the viewport (in screen space)
  37991. * @param y defines the y coordinate of the viewport (in screen space)
  37992. * @param width defines the width of the viewport (in screen space)
  37993. * @param height defines the height of the viewport (in screen space)
  37994. * @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
  37995. */
  37996. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  37997. /**
  37998. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  37999. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  38000. * @param y defines the y-coordinate of the corner of the clear rectangle
  38001. * @param width defines the width of the clear rectangle
  38002. * @param height defines the height of the clear rectangle
  38003. * @param clearColor defines the clear color
  38004. */
  38005. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  38006. /**
  38007. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  38008. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  38009. * @param y defines the y-coordinate of the corner of the clear rectangle
  38010. * @param width defines the width of the clear rectangle
  38011. * @param height defines the height of the clear rectangle
  38012. */
  38013. enableScissor(x: number, y: number, width: number, height: number): void;
  38014. /**
  38015. * Disable previously set scissor test rectangle
  38016. */
  38017. disableScissor(): void;
  38018. protected _reportDrawCall(): void;
  38019. /**
  38020. * Initializes a webVR display and starts listening to display change events
  38021. * The onVRDisplayChangedObservable will be notified upon these changes
  38022. * @returns The onVRDisplayChangedObservable
  38023. */
  38024. initWebVR(): Observable<IDisplayChangedEventArgs>;
  38025. /** @hidden */
  38026. _prepareVRComponent(): void;
  38027. /** @hidden */
  38028. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  38029. /** @hidden */
  38030. _submitVRFrame(): void;
  38031. /**
  38032. * Call this function to leave webVR mode
  38033. * Will do nothing if webVR is not supported or if there is no webVR device
  38034. * @see https://doc.babylonjs.com/how_to/webvr_camera
  38035. */
  38036. disableVR(): void;
  38037. /**
  38038. * Gets a boolean indicating that the system is in VR mode and is presenting
  38039. * @returns true if VR mode is engaged
  38040. */
  38041. isVRPresenting(): boolean;
  38042. /** @hidden */
  38043. _requestVRFrame(): void;
  38044. /** @hidden */
  38045. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38046. /**
  38047. * Gets the source code of the vertex shader associated with a specific webGL program
  38048. * @param program defines the program to use
  38049. * @returns a string containing the source code of the vertex shader associated with the program
  38050. */
  38051. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  38052. /**
  38053. * Gets the source code of the fragment shader associated with a specific webGL program
  38054. * @param program defines the program to use
  38055. * @returns a string containing the source code of the fragment shader associated with the program
  38056. */
  38057. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  38058. /**
  38059. * Sets a depth stencil texture from a render target to the according uniform.
  38060. * @param channel The texture channel
  38061. * @param uniform The uniform to set
  38062. * @param texture The render target texture containing the depth stencil texture to apply
  38063. */
  38064. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  38065. /**
  38066. * Sets a texture to the webGL context from a postprocess
  38067. * @param channel defines the channel to use
  38068. * @param postProcess defines the source postprocess
  38069. */
  38070. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  38071. /**
  38072. * Binds the output of the passed in post process to the texture channel specified
  38073. * @param channel The channel the texture should be bound to
  38074. * @param postProcess The post process which's output should be bound
  38075. */
  38076. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  38077. protected _rebuildBuffers(): void;
  38078. /** @hidden */
  38079. _renderFrame(): void;
  38080. _renderLoop(): void;
  38081. /** @hidden */
  38082. _renderViews(): boolean;
  38083. /**
  38084. * Toggle full screen mode
  38085. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38086. */
  38087. switchFullscreen(requestPointerLock: boolean): void;
  38088. /**
  38089. * Enters full screen mode
  38090. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38091. */
  38092. enterFullscreen(requestPointerLock: boolean): void;
  38093. /**
  38094. * Exits full screen mode
  38095. */
  38096. exitFullscreen(): void;
  38097. /**
  38098. * Enters Pointerlock mode
  38099. */
  38100. enterPointerlock(): void;
  38101. /**
  38102. * Exits Pointerlock mode
  38103. */
  38104. exitPointerlock(): void;
  38105. /**
  38106. * Begin a new frame
  38107. */
  38108. beginFrame(): void;
  38109. /**
  38110. * Enf the current frame
  38111. */
  38112. endFrame(): void;
  38113. resize(): void;
  38114. /**
  38115. * Force a specific size of the canvas
  38116. * @param width defines the new canvas' width
  38117. * @param height defines the new canvas' height
  38118. * @returns true if the size was changed
  38119. */
  38120. setSize(width: number, height: number): boolean;
  38121. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  38122. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38123. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38124. _releaseTexture(texture: InternalTexture): void;
  38125. /**
  38126. * @hidden
  38127. * Rescales a texture
  38128. * @param source input texutre
  38129. * @param destination destination texture
  38130. * @param scene scene to use to render the resize
  38131. * @param internalFormat format to use when resizing
  38132. * @param onComplete callback to be called when resize has completed
  38133. */
  38134. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  38135. /**
  38136. * Gets the current framerate
  38137. * @returns a number representing the framerate
  38138. */
  38139. getFps(): number;
  38140. /**
  38141. * Gets the time spent between current and previous frame
  38142. * @returns a number representing the delta time in ms
  38143. */
  38144. getDeltaTime(): number;
  38145. private _measureFps;
  38146. /** @hidden */
  38147. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  38148. /**
  38149. * Updates the sample count of a render target texture
  38150. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  38151. * @param texture defines the texture to update
  38152. * @param samples defines the sample count to set
  38153. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  38154. */
  38155. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  38156. /**
  38157. * Updates a depth texture Comparison Mode and Function.
  38158. * If the comparison Function is equal to 0, the mode will be set to none.
  38159. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  38160. * @param texture The texture to set the comparison function for
  38161. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  38162. */
  38163. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  38164. /**
  38165. * Creates a webGL buffer to use with instanciation
  38166. * @param capacity defines the size of the buffer
  38167. * @returns the webGL buffer
  38168. */
  38169. createInstancesBuffer(capacity: number): DataBuffer;
  38170. /**
  38171. * Delete a webGL buffer used with instanciation
  38172. * @param buffer defines the webGL buffer to delete
  38173. */
  38174. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  38175. private _clientWaitAsync;
  38176. /** @hidden */
  38177. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  38178. dispose(): void;
  38179. private _disableTouchAction;
  38180. /**
  38181. * Display the loading screen
  38182. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38183. */
  38184. displayLoadingUI(): void;
  38185. /**
  38186. * Hide the loading screen
  38187. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38188. */
  38189. hideLoadingUI(): void;
  38190. /**
  38191. * Gets the current loading screen object
  38192. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38193. */
  38194. get loadingScreen(): ILoadingScreen;
  38195. /**
  38196. * Sets the current loading screen object
  38197. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38198. */
  38199. set loadingScreen(loadingScreen: ILoadingScreen);
  38200. /**
  38201. * Sets the current loading screen text
  38202. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38203. */
  38204. set loadingUIText(text: string);
  38205. /**
  38206. * Sets the current loading screen background color
  38207. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38208. */
  38209. set loadingUIBackgroundColor(color: string);
  38210. /** Pointerlock and fullscreen */
  38211. /**
  38212. * Ask the browser to promote the current element to pointerlock mode
  38213. * @param element defines the DOM element to promote
  38214. */
  38215. static _RequestPointerlock(element: HTMLElement): void;
  38216. /**
  38217. * Asks the browser to exit pointerlock mode
  38218. */
  38219. static _ExitPointerlock(): void;
  38220. /**
  38221. * Ask the browser to promote the current element to fullscreen rendering mode
  38222. * @param element defines the DOM element to promote
  38223. */
  38224. static _RequestFullscreen(element: HTMLElement): void;
  38225. /**
  38226. * Asks the browser to exit fullscreen mode
  38227. */
  38228. static _ExitFullscreen(): void;
  38229. }
  38230. }
  38231. declare module BABYLON {
  38232. /**
  38233. * The engine store class is responsible to hold all the instances of Engine and Scene created
  38234. * during the life time of the application.
  38235. */
  38236. export class EngineStore {
  38237. /** Gets the list of created engines */
  38238. static Instances: Engine[];
  38239. /** @hidden */
  38240. static _LastCreatedScene: Nullable<Scene>;
  38241. /**
  38242. * Gets the latest created engine
  38243. */
  38244. static get LastCreatedEngine(): Nullable<Engine>;
  38245. /**
  38246. * Gets the latest created scene
  38247. */
  38248. static get LastCreatedScene(): Nullable<Scene>;
  38249. /**
  38250. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38251. * @ignorenaming
  38252. */
  38253. static UseFallbackTexture: boolean;
  38254. /**
  38255. * Texture content used if a texture cannot loaded
  38256. * @ignorenaming
  38257. */
  38258. static FallbackTexture: string;
  38259. }
  38260. }
  38261. declare module BABYLON {
  38262. /**
  38263. * Helper class that provides a small promise polyfill
  38264. */
  38265. export class PromisePolyfill {
  38266. /**
  38267. * Static function used to check if the polyfill is required
  38268. * If this is the case then the function will inject the polyfill to window.Promise
  38269. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38270. */
  38271. static Apply(force?: boolean): void;
  38272. }
  38273. }
  38274. declare module BABYLON {
  38275. /**
  38276. * Interface for screenshot methods with describe argument called `size` as object with options
  38277. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  38278. */
  38279. export interface IScreenshotSize {
  38280. /**
  38281. * number in pixels for canvas height
  38282. */
  38283. height?: number;
  38284. /**
  38285. * multiplier allowing render at a higher or lower resolution
  38286. * If value is defined then height and width will be ignored and taken from camera
  38287. */
  38288. precision?: number;
  38289. /**
  38290. * number in pixels for canvas width
  38291. */
  38292. width?: number;
  38293. }
  38294. }
  38295. declare module BABYLON {
  38296. interface IColor4Like {
  38297. r: float;
  38298. g: float;
  38299. b: float;
  38300. a: float;
  38301. }
  38302. /**
  38303. * Class containing a set of static utilities functions
  38304. */
  38305. export class Tools {
  38306. /**
  38307. * Gets or sets the base URL to use to load assets
  38308. */
  38309. static get BaseUrl(): string;
  38310. static set BaseUrl(value: string);
  38311. /**
  38312. * Enable/Disable Custom HTTP Request Headers globally.
  38313. * default = false
  38314. * @see CustomRequestHeaders
  38315. */
  38316. static UseCustomRequestHeaders: boolean;
  38317. /**
  38318. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  38319. * i.e. when loading files, where the server/service expects an Authorization header
  38320. */
  38321. static CustomRequestHeaders: {
  38322. [key: string]: string;
  38323. };
  38324. /**
  38325. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  38326. */
  38327. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  38328. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  38329. /**
  38330. * Default behaviour for cors in the application.
  38331. * It can be a string if the expected behavior is identical in the entire app.
  38332. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  38333. */
  38334. static get CorsBehavior(): string | ((url: string | string[]) => string);
  38335. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  38336. /**
  38337. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38338. * @ignorenaming
  38339. */
  38340. static get UseFallbackTexture(): boolean;
  38341. static set UseFallbackTexture(value: boolean);
  38342. /**
  38343. * Use this object to register external classes like custom textures or material
  38344. * to allow the laoders to instantiate them
  38345. */
  38346. static get RegisteredExternalClasses(): {
  38347. [key: string]: Object;
  38348. };
  38349. static set RegisteredExternalClasses(classes: {
  38350. [key: string]: Object;
  38351. });
  38352. /**
  38353. * Texture content used if a texture cannot loaded
  38354. * @ignorenaming
  38355. */
  38356. static get fallbackTexture(): string;
  38357. static set fallbackTexture(value: string);
  38358. /**
  38359. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  38360. * @param u defines the coordinate on X axis
  38361. * @param v defines the coordinate on Y axis
  38362. * @param width defines the width of the source data
  38363. * @param height defines the height of the source data
  38364. * @param pixels defines the source byte array
  38365. * @param color defines the output color
  38366. */
  38367. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  38368. /**
  38369. * Interpolates between a and b via alpha
  38370. * @param a The lower value (returned when alpha = 0)
  38371. * @param b The upper value (returned when alpha = 1)
  38372. * @param alpha The interpolation-factor
  38373. * @return The mixed value
  38374. */
  38375. static Mix(a: number, b: number, alpha: number): number;
  38376. /**
  38377. * Tries to instantiate a new object from a given class name
  38378. * @param className defines the class name to instantiate
  38379. * @returns the new object or null if the system was not able to do the instantiation
  38380. */
  38381. static Instantiate(className: string): any;
  38382. /**
  38383. * Provides a slice function that will work even on IE
  38384. * @param data defines the array to slice
  38385. * @param start defines the start of the data (optional)
  38386. * @param end defines the end of the data (optional)
  38387. * @returns the new sliced array
  38388. */
  38389. static Slice<T>(data: T, start?: number, end?: number): T;
  38390. /**
  38391. * Polyfill for setImmediate
  38392. * @param action defines the action to execute after the current execution block
  38393. */
  38394. static SetImmediate(action: () => void): void;
  38395. /**
  38396. * Function indicating if a number is an exponent of 2
  38397. * @param value defines the value to test
  38398. * @returns true if the value is an exponent of 2
  38399. */
  38400. static IsExponentOfTwo(value: number): boolean;
  38401. private static _tmpFloatArray;
  38402. /**
  38403. * Returns the nearest 32-bit single precision float representation of a Number
  38404. * @param value A Number. If the parameter is of a different type, it will get converted
  38405. * to a number or to NaN if it cannot be converted
  38406. * @returns number
  38407. */
  38408. static FloatRound(value: number): number;
  38409. /**
  38410. * Extracts the filename from a path
  38411. * @param path defines the path to use
  38412. * @returns the filename
  38413. */
  38414. static GetFilename(path: string): string;
  38415. /**
  38416. * Extracts the "folder" part of a path (everything before the filename).
  38417. * @param uri The URI to extract the info from
  38418. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  38419. * @returns The "folder" part of the path
  38420. */
  38421. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  38422. /**
  38423. * Extracts text content from a DOM element hierarchy
  38424. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  38425. */
  38426. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  38427. /**
  38428. * Convert an angle in radians to degrees
  38429. * @param angle defines the angle to convert
  38430. * @returns the angle in degrees
  38431. */
  38432. static ToDegrees(angle: number): number;
  38433. /**
  38434. * Convert an angle in degrees to radians
  38435. * @param angle defines the angle to convert
  38436. * @returns the angle in radians
  38437. */
  38438. static ToRadians(angle: number): number;
  38439. /**
  38440. * Returns an array if obj is not an array
  38441. * @param obj defines the object to evaluate as an array
  38442. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  38443. * @returns either obj directly if obj is an array or a new array containing obj
  38444. */
  38445. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  38446. /**
  38447. * Gets the pointer prefix to use
  38448. * @param engine defines the engine we are finding the prefix for
  38449. * @returns "pointer" if touch is enabled. Else returns "mouse"
  38450. */
  38451. static GetPointerPrefix(engine: Engine): string;
  38452. /**
  38453. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  38454. * @param url define the url we are trying
  38455. * @param element define the dom element where to configure the cors policy
  38456. */
  38457. static SetCorsBehavior(url: string | string[], element: {
  38458. crossOrigin: string | null;
  38459. }): void;
  38460. /**
  38461. * Removes unwanted characters from an url
  38462. * @param url defines the url to clean
  38463. * @returns the cleaned url
  38464. */
  38465. static CleanUrl(url: string): string;
  38466. /**
  38467. * Gets or sets a function used to pre-process url before using them to load assets
  38468. */
  38469. static get PreprocessUrl(): (url: string) => string;
  38470. static set PreprocessUrl(processor: (url: string) => string);
  38471. /**
  38472. * Loads an image as an HTMLImageElement.
  38473. * @param input url string, ArrayBuffer, or Blob to load
  38474. * @param onLoad callback called when the image successfully loads
  38475. * @param onError callback called when the image fails to load
  38476. * @param offlineProvider offline provider for caching
  38477. * @param mimeType optional mime type
  38478. * @returns the HTMLImageElement of the loaded image
  38479. */
  38480. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  38481. /**
  38482. * Loads a file from a url
  38483. * @param url url string, ArrayBuffer, or Blob to load
  38484. * @param onSuccess callback called when the file successfully loads
  38485. * @param onProgress callback called while file is loading (if the server supports this mode)
  38486. * @param offlineProvider defines the offline provider for caching
  38487. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38488. * @param onError callback called when the file fails to load
  38489. * @returns a file request object
  38490. */
  38491. 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;
  38492. /**
  38493. * Loads a file from a url
  38494. * @param url the file url to load
  38495. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38496. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  38497. */
  38498. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  38499. /**
  38500. * Load a script (identified by an url). When the url returns, the
  38501. * content of this file is added into a new script element, attached to the DOM (body element)
  38502. * @param scriptUrl defines the url of the script to laod
  38503. * @param onSuccess defines the callback called when the script is loaded
  38504. * @param onError defines the callback to call if an error occurs
  38505. * @param scriptId defines the id of the script element
  38506. */
  38507. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  38508. /**
  38509. * Load an asynchronous script (identified by an url). When the url returns, the
  38510. * content of this file is added into a new script element, attached to the DOM (body element)
  38511. * @param scriptUrl defines the url of the script to laod
  38512. * @param scriptId defines the id of the script element
  38513. * @returns a promise request object
  38514. */
  38515. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  38516. /**
  38517. * Loads a file from a blob
  38518. * @param fileToLoad defines the blob to use
  38519. * @param callback defines the callback to call when data is loaded
  38520. * @param progressCallback defines the callback to call during loading process
  38521. * @returns a file request object
  38522. */
  38523. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  38524. /**
  38525. * Reads a file from a File object
  38526. * @param file defines the file to load
  38527. * @param onSuccess defines the callback to call when data is loaded
  38528. * @param onProgress defines the callback to call during loading process
  38529. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  38530. * @param onError defines the callback to call when an error occurs
  38531. * @returns a file request object
  38532. */
  38533. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38534. /**
  38535. * Creates a data url from a given string content
  38536. * @param content defines the content to convert
  38537. * @returns the new data url link
  38538. */
  38539. static FileAsURL(content: string): string;
  38540. /**
  38541. * Format the given number to a specific decimal format
  38542. * @param value defines the number to format
  38543. * @param decimals defines the number of decimals to use
  38544. * @returns the formatted string
  38545. */
  38546. static Format(value: number, decimals?: number): string;
  38547. /**
  38548. * Tries to copy an object by duplicating every property
  38549. * @param source defines the source object
  38550. * @param destination defines the target object
  38551. * @param doNotCopyList defines a list of properties to avoid
  38552. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  38553. */
  38554. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  38555. /**
  38556. * Gets a boolean indicating if the given object has no own property
  38557. * @param obj defines the object to test
  38558. * @returns true if object has no own property
  38559. */
  38560. static IsEmpty(obj: any): boolean;
  38561. /**
  38562. * Function used to register events at window level
  38563. * @param windowElement defines the Window object to use
  38564. * @param events defines the events to register
  38565. */
  38566. static RegisterTopRootEvents(windowElement: Window, events: {
  38567. name: string;
  38568. handler: Nullable<(e: FocusEvent) => any>;
  38569. }[]): void;
  38570. /**
  38571. * Function used to unregister events from window level
  38572. * @param windowElement defines the Window object to use
  38573. * @param events defines the events to unregister
  38574. */
  38575. static UnregisterTopRootEvents(windowElement: Window, events: {
  38576. name: string;
  38577. handler: Nullable<(e: FocusEvent) => any>;
  38578. }[]): void;
  38579. /**
  38580. * @ignore
  38581. */
  38582. static _ScreenshotCanvas: HTMLCanvasElement;
  38583. /**
  38584. * Dumps the current bound framebuffer
  38585. * @param width defines the rendering width
  38586. * @param height defines the rendering height
  38587. * @param engine defines the hosting engine
  38588. * @param successCallback defines the callback triggered once the data are available
  38589. * @param mimeType defines the mime type of the result
  38590. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  38591. */
  38592. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38593. /**
  38594. * Converts the canvas data to blob.
  38595. * This acts as a polyfill for browsers not supporting the to blob function.
  38596. * @param canvas Defines the canvas to extract the data from
  38597. * @param successCallback Defines the callback triggered once the data are available
  38598. * @param mimeType Defines the mime type of the result
  38599. */
  38600. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  38601. /**
  38602. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  38603. * @param successCallback defines the callback triggered once the data are available
  38604. * @param mimeType defines the mime type of the result
  38605. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  38606. */
  38607. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38608. /**
  38609. * Downloads a blob in the browser
  38610. * @param blob defines the blob to download
  38611. * @param fileName defines the name of the downloaded file
  38612. */
  38613. static Download(blob: Blob, fileName: string): void;
  38614. /**
  38615. * Captures a screenshot of the current rendering
  38616. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38617. * @param engine defines the rendering engine
  38618. * @param camera defines the source camera
  38619. * @param size This parameter can be set to a single number or to an object with the
  38620. * following (optional) properties: precision, width, height. If a single number is passed,
  38621. * it will be used for both width and height. If an object is passed, the screenshot size
  38622. * will be derived from the parameters. The precision property is a multiplier allowing
  38623. * rendering at a higher or lower resolution
  38624. * @param successCallback defines the callback receives a single parameter which contains the
  38625. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38626. * src parameter of an <img> to display it
  38627. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38628. * Check your browser for supported MIME types
  38629. */
  38630. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  38631. /**
  38632. * Captures a screenshot of the current rendering
  38633. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38634. * @param engine defines the rendering engine
  38635. * @param camera defines the source camera
  38636. * @param size This parameter can be set to a single number or to an object with the
  38637. * following (optional) properties: precision, width, height. If a single number is passed,
  38638. * it will be used for both width and height. If an object is passed, the screenshot size
  38639. * will be derived from the parameters. The precision property is a multiplier allowing
  38640. * rendering at a higher or lower resolution
  38641. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38642. * Check your browser for supported MIME types
  38643. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38644. * to the src parameter of an <img> to display it
  38645. */
  38646. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  38647. /**
  38648. * Generates an image screenshot from the specified camera.
  38649. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38650. * @param engine The engine to use for rendering
  38651. * @param camera The camera to use for rendering
  38652. * @param size This parameter can be set to a single number or to an object with the
  38653. * following (optional) properties: precision, width, height. If a single number is passed,
  38654. * it will be used for both width and height. If an object is passed, the screenshot size
  38655. * will be derived from the parameters. The precision property is a multiplier allowing
  38656. * rendering at a higher or lower resolution
  38657. * @param successCallback The callback receives a single parameter which contains the
  38658. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38659. * src parameter of an <img> to display it
  38660. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38661. * Check your browser for supported MIME types
  38662. * @param samples Texture samples (default: 1)
  38663. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38664. * @param fileName A name for for the downloaded file.
  38665. */
  38666. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  38667. /**
  38668. * Generates an image screenshot from the specified camera.
  38669. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38670. * @param engine The engine to use for rendering
  38671. * @param camera The camera to use for rendering
  38672. * @param size This parameter can be set to a single number or to an object with the
  38673. * following (optional) properties: precision, width, height. If a single number is passed,
  38674. * it will be used for both width and height. If an object is passed, the screenshot size
  38675. * will be derived from the parameters. The precision property is a multiplier allowing
  38676. * rendering at a higher or lower resolution
  38677. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38678. * Check your browser for supported MIME types
  38679. * @param samples Texture samples (default: 1)
  38680. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38681. * @param fileName A name for for the downloaded file.
  38682. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38683. * to the src parameter of an <img> to display it
  38684. */
  38685. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  38686. /**
  38687. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  38688. * Be aware Math.random() could cause collisions, but:
  38689. * "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"
  38690. * @returns a pseudo random id
  38691. */
  38692. static RandomId(): string;
  38693. /**
  38694. * Test if the given uri is a base64 string
  38695. * @param uri The uri to test
  38696. * @return True if the uri is a base64 string or false otherwise
  38697. */
  38698. static IsBase64(uri: string): boolean;
  38699. /**
  38700. * Decode the given base64 uri.
  38701. * @param uri The uri to decode
  38702. * @return The decoded base64 data.
  38703. */
  38704. static DecodeBase64(uri: string): ArrayBuffer;
  38705. /**
  38706. * Gets the absolute url.
  38707. * @param url the input url
  38708. * @return the absolute url
  38709. */
  38710. static GetAbsoluteUrl(url: string): string;
  38711. /**
  38712. * No log
  38713. */
  38714. static readonly NoneLogLevel: number;
  38715. /**
  38716. * Only message logs
  38717. */
  38718. static readonly MessageLogLevel: number;
  38719. /**
  38720. * Only warning logs
  38721. */
  38722. static readonly WarningLogLevel: number;
  38723. /**
  38724. * Only error logs
  38725. */
  38726. static readonly ErrorLogLevel: number;
  38727. /**
  38728. * All logs
  38729. */
  38730. static readonly AllLogLevel: number;
  38731. /**
  38732. * Gets a value indicating the number of loading errors
  38733. * @ignorenaming
  38734. */
  38735. static get errorsCount(): number;
  38736. /**
  38737. * Callback called when a new log is added
  38738. */
  38739. static OnNewCacheEntry: (entry: string) => void;
  38740. /**
  38741. * Log a message to the console
  38742. * @param message defines the message to log
  38743. */
  38744. static Log(message: string): void;
  38745. /**
  38746. * Write a warning message to the console
  38747. * @param message defines the message to log
  38748. */
  38749. static Warn(message: string): void;
  38750. /**
  38751. * Write an error message to the console
  38752. * @param message defines the message to log
  38753. */
  38754. static Error(message: string): void;
  38755. /**
  38756. * Gets current log cache (list of logs)
  38757. */
  38758. static get LogCache(): string;
  38759. /**
  38760. * Clears the log cache
  38761. */
  38762. static ClearLogCache(): void;
  38763. /**
  38764. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  38765. */
  38766. static set LogLevels(level: number);
  38767. /**
  38768. * Checks if the window object exists
  38769. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  38770. */
  38771. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  38772. /**
  38773. * No performance log
  38774. */
  38775. static readonly PerformanceNoneLogLevel: number;
  38776. /**
  38777. * Use user marks to log performance
  38778. */
  38779. static readonly PerformanceUserMarkLogLevel: number;
  38780. /**
  38781. * Log performance to the console
  38782. */
  38783. static readonly PerformanceConsoleLogLevel: number;
  38784. private static _performance;
  38785. /**
  38786. * Sets the current performance log level
  38787. */
  38788. static set PerformanceLogLevel(level: number);
  38789. private static _StartPerformanceCounterDisabled;
  38790. private static _EndPerformanceCounterDisabled;
  38791. private static _StartUserMark;
  38792. private static _EndUserMark;
  38793. private static _StartPerformanceConsole;
  38794. private static _EndPerformanceConsole;
  38795. /**
  38796. * Starts a performance counter
  38797. */
  38798. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38799. /**
  38800. * Ends a specific performance coutner
  38801. */
  38802. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38803. /**
  38804. * Gets either window.performance.now() if supported or Date.now() else
  38805. */
  38806. static get Now(): number;
  38807. /**
  38808. * This method will return the name of the class used to create the instance of the given object.
  38809. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  38810. * @param object the object to get the class name from
  38811. * @param isType defines if the object is actually a type
  38812. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  38813. */
  38814. static GetClassName(object: any, isType?: boolean): string;
  38815. /**
  38816. * Gets the first element of an array satisfying a given predicate
  38817. * @param array defines the array to browse
  38818. * @param predicate defines the predicate to use
  38819. * @returns null if not found or the element
  38820. */
  38821. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  38822. /**
  38823. * This method will return the name of the full name of the class, including its owning module (if any).
  38824. * 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).
  38825. * @param object the object to get the class name from
  38826. * @param isType defines if the object is actually a type
  38827. * @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.
  38828. * @ignorenaming
  38829. */
  38830. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  38831. /**
  38832. * Returns a promise that resolves after the given amount of time.
  38833. * @param delay Number of milliseconds to delay
  38834. * @returns Promise that resolves after the given amount of time
  38835. */
  38836. static DelayAsync(delay: number): Promise<void>;
  38837. /**
  38838. * Utility function to detect if the current user agent is Safari
  38839. * @returns whether or not the current user agent is safari
  38840. */
  38841. static IsSafari(): boolean;
  38842. }
  38843. /**
  38844. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  38845. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  38846. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  38847. * @param name The name of the class, case should be preserved
  38848. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  38849. */
  38850. export function className(name: string, module?: string): (target: Object) => void;
  38851. /**
  38852. * An implementation of a loop for asynchronous functions.
  38853. */
  38854. export class AsyncLoop {
  38855. /**
  38856. * Defines the number of iterations for the loop
  38857. */
  38858. iterations: number;
  38859. /**
  38860. * Defines the current index of the loop.
  38861. */
  38862. index: number;
  38863. private _done;
  38864. private _fn;
  38865. private _successCallback;
  38866. /**
  38867. * Constructor.
  38868. * @param iterations the number of iterations.
  38869. * @param func the function to run each iteration
  38870. * @param successCallback the callback that will be called upon succesful execution
  38871. * @param offset starting offset.
  38872. */
  38873. constructor(
  38874. /**
  38875. * Defines the number of iterations for the loop
  38876. */
  38877. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  38878. /**
  38879. * Execute the next iteration. Must be called after the last iteration was finished.
  38880. */
  38881. executeNext(): void;
  38882. /**
  38883. * Break the loop and run the success callback.
  38884. */
  38885. breakLoop(): void;
  38886. /**
  38887. * Create and run an async loop.
  38888. * @param iterations the number of iterations.
  38889. * @param fn the function to run each iteration
  38890. * @param successCallback the callback that will be called upon succesful execution
  38891. * @param offset starting offset.
  38892. * @returns the created async loop object
  38893. */
  38894. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  38895. /**
  38896. * A for-loop that will run a given number of iterations synchronous and the rest async.
  38897. * @param iterations total number of iterations
  38898. * @param syncedIterations number of synchronous iterations in each async iteration.
  38899. * @param fn the function to call each iteration.
  38900. * @param callback a success call back that will be called when iterating stops.
  38901. * @param breakFunction a break condition (optional)
  38902. * @param timeout timeout settings for the setTimeout function. default - 0.
  38903. * @returns the created async loop object
  38904. */
  38905. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  38906. }
  38907. }
  38908. declare module BABYLON {
  38909. /**
  38910. * This class implement a typical dictionary using a string as key and the generic type T as value.
  38911. * The underlying implementation relies on an associative array to ensure the best performances.
  38912. * The value can be anything including 'null' but except 'undefined'
  38913. */
  38914. export class StringDictionary<T> {
  38915. /**
  38916. * This will clear this dictionary and copy the content from the 'source' one.
  38917. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  38918. * @param source the dictionary to take the content from and copy to this dictionary
  38919. */
  38920. copyFrom(source: StringDictionary<T>): void;
  38921. /**
  38922. * Get a value based from its key
  38923. * @param key the given key to get the matching value from
  38924. * @return the value if found, otherwise undefined is returned
  38925. */
  38926. get(key: string): T | undefined;
  38927. /**
  38928. * Get a value from its key or add it if it doesn't exist.
  38929. * This method will ensure you that a given key/data will be present in the dictionary.
  38930. * @param key the given key to get the matching value from
  38931. * @param factory the factory that will create the value if the key is not present in the dictionary.
  38932. * The factory will only be invoked if there's no data for the given key.
  38933. * @return the value corresponding to the key.
  38934. */
  38935. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  38936. /**
  38937. * Get a value from its key if present in the dictionary otherwise add it
  38938. * @param key the key to get the value from
  38939. * @param val if there's no such key/value pair in the dictionary add it with this value
  38940. * @return the value corresponding to the key
  38941. */
  38942. getOrAdd(key: string, val: T): T;
  38943. /**
  38944. * Check if there's a given key in the dictionary
  38945. * @param key the key to check for
  38946. * @return true if the key is present, false otherwise
  38947. */
  38948. contains(key: string): boolean;
  38949. /**
  38950. * Add a new key and its corresponding value
  38951. * @param key the key to add
  38952. * @param value the value corresponding to the key
  38953. * @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
  38954. */
  38955. add(key: string, value: T): boolean;
  38956. /**
  38957. * Update a specific value associated to a key
  38958. * @param key defines the key to use
  38959. * @param value defines the value to store
  38960. * @returns true if the value was updated (or false if the key was not found)
  38961. */
  38962. set(key: string, value: T): boolean;
  38963. /**
  38964. * Get the element of the given key and remove it from the dictionary
  38965. * @param key defines the key to search
  38966. * @returns the value associated with the key or null if not found
  38967. */
  38968. getAndRemove(key: string): Nullable<T>;
  38969. /**
  38970. * Remove a key/value from the dictionary.
  38971. * @param key the key to remove
  38972. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  38973. */
  38974. remove(key: string): boolean;
  38975. /**
  38976. * Clear the whole content of the dictionary
  38977. */
  38978. clear(): void;
  38979. /**
  38980. * Gets the current count
  38981. */
  38982. get count(): number;
  38983. /**
  38984. * Execute a callback on each key/val of the dictionary.
  38985. * Note that you can remove any element in this dictionary in the callback implementation
  38986. * @param callback the callback to execute on a given key/value pair
  38987. */
  38988. forEach(callback: (key: string, val: T) => void): void;
  38989. /**
  38990. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  38991. * If the callback returns null or undefined the method will iterate to the next key/value pair
  38992. * Note that you can remove any element in this dictionary in the callback implementation
  38993. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  38994. * @returns the first item
  38995. */
  38996. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  38997. private _count;
  38998. private _data;
  38999. }
  39000. }
  39001. declare module BABYLON {
  39002. /** @hidden */
  39003. export interface ICollisionCoordinator {
  39004. createCollider(): Collider;
  39005. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  39006. init(scene: Scene): void;
  39007. }
  39008. /** @hidden */
  39009. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  39010. private _scene;
  39011. private _scaledPosition;
  39012. private _scaledVelocity;
  39013. private _finalPosition;
  39014. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  39015. createCollider(): Collider;
  39016. init(scene: Scene): void;
  39017. private _collideWithWorld;
  39018. }
  39019. }
  39020. declare module BABYLON {
  39021. /**
  39022. * Class used to manage all inputs for the scene.
  39023. */
  39024. export class InputManager {
  39025. /** The distance in pixel that you have to move to prevent some events */
  39026. static DragMovementThreshold: number;
  39027. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  39028. static LongPressDelay: number;
  39029. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  39030. static DoubleClickDelay: number;
  39031. /** If you need to check double click without raising a single click at first click, enable this flag */
  39032. static ExclusiveDoubleClickMode: boolean;
  39033. /** 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. */
  39034. private _alreadyAttached;
  39035. private _wheelEventName;
  39036. private _onPointerMove;
  39037. private _onPointerDown;
  39038. private _onPointerUp;
  39039. private _initClickEvent;
  39040. private _initActionManager;
  39041. private _delayedSimpleClick;
  39042. private _delayedSimpleClickTimeout;
  39043. private _previousDelayedSimpleClickTimeout;
  39044. private _meshPickProceed;
  39045. private _previousButtonPressed;
  39046. private _currentPickResult;
  39047. private _previousPickResult;
  39048. private _totalPointersPressed;
  39049. private _doubleClickOccured;
  39050. private _pointerOverMesh;
  39051. private _pickedDownMesh;
  39052. private _pickedUpMesh;
  39053. private _pointerX;
  39054. private _pointerY;
  39055. private _unTranslatedPointerX;
  39056. private _unTranslatedPointerY;
  39057. private _startingPointerPosition;
  39058. private _previousStartingPointerPosition;
  39059. private _startingPointerTime;
  39060. private _previousStartingPointerTime;
  39061. private _pointerCaptures;
  39062. private _meshUnderPointerId;
  39063. private _onKeyDown;
  39064. private _onKeyUp;
  39065. private _onCanvasFocusObserver;
  39066. private _onCanvasBlurObserver;
  39067. private _scene;
  39068. /**
  39069. * Creates a new InputManager
  39070. * @param scene defines the hosting scene
  39071. */
  39072. constructor(scene: Scene);
  39073. /**
  39074. * Gets the mesh that is currently under the pointer
  39075. */
  39076. get meshUnderPointer(): Nullable<AbstractMesh>;
  39077. /**
  39078. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  39079. * @param pointerId the pointer id to use
  39080. * @returns The mesh under this pointer id or null if not found
  39081. */
  39082. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  39083. /**
  39084. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  39085. */
  39086. get unTranslatedPointer(): Vector2;
  39087. /**
  39088. * Gets or sets the current on-screen X position of the pointer
  39089. */
  39090. get pointerX(): number;
  39091. set pointerX(value: number);
  39092. /**
  39093. * Gets or sets the current on-screen Y position of the pointer
  39094. */
  39095. get pointerY(): number;
  39096. set pointerY(value: number);
  39097. private _updatePointerPosition;
  39098. private _processPointerMove;
  39099. private _setRayOnPointerInfo;
  39100. private _checkPrePointerObservable;
  39101. /**
  39102. * Use this method to simulate a pointer move on a mesh
  39103. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39104. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39105. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39106. */
  39107. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39108. /**
  39109. * Use this method to simulate a pointer down on a mesh
  39110. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39111. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39112. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39113. */
  39114. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39115. private _processPointerDown;
  39116. /** @hidden */
  39117. _isPointerSwiping(): boolean;
  39118. /**
  39119. * Use this method to simulate a pointer up on a mesh
  39120. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39121. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39122. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39123. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39124. */
  39125. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  39126. private _processPointerUp;
  39127. /**
  39128. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39129. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39130. * @returns true if the pointer was captured
  39131. */
  39132. isPointerCaptured(pointerId?: number): boolean;
  39133. /**
  39134. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39135. * @param attachUp defines if you want to attach events to pointerup
  39136. * @param attachDown defines if you want to attach events to pointerdown
  39137. * @param attachMove defines if you want to attach events to pointermove
  39138. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  39139. */
  39140. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  39141. /**
  39142. * Detaches all event handlers
  39143. */
  39144. detachControl(): void;
  39145. /**
  39146. * Force the value of meshUnderPointer
  39147. * @param mesh defines the mesh to use
  39148. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  39149. */
  39150. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  39151. /**
  39152. * Gets the mesh under the pointer
  39153. * @returns a Mesh or null if no mesh is under the pointer
  39154. */
  39155. getPointerOverMesh(): Nullable<AbstractMesh>;
  39156. }
  39157. }
  39158. declare module BABYLON {
  39159. /**
  39160. * This class defines the direct association between an animation and a target
  39161. */
  39162. export class TargetedAnimation {
  39163. /**
  39164. * Animation to perform
  39165. */
  39166. animation: Animation;
  39167. /**
  39168. * Target to animate
  39169. */
  39170. target: any;
  39171. /**
  39172. * Returns the string "TargetedAnimation"
  39173. * @returns "TargetedAnimation"
  39174. */
  39175. getClassName(): string;
  39176. /**
  39177. * Serialize the object
  39178. * @returns the JSON object representing the current entity
  39179. */
  39180. serialize(): any;
  39181. }
  39182. /**
  39183. * Use this class to create coordinated animations on multiple targets
  39184. */
  39185. export class AnimationGroup implements IDisposable {
  39186. /** The name of the animation group */
  39187. name: string;
  39188. private _scene;
  39189. private _targetedAnimations;
  39190. private _animatables;
  39191. private _from;
  39192. private _to;
  39193. private _isStarted;
  39194. private _isPaused;
  39195. private _speedRatio;
  39196. private _loopAnimation;
  39197. private _isAdditive;
  39198. /**
  39199. * Gets or sets the unique id of the node
  39200. */
  39201. uniqueId: number;
  39202. /**
  39203. * This observable will notify when one animation have ended
  39204. */
  39205. onAnimationEndObservable: Observable<TargetedAnimation>;
  39206. /**
  39207. * Observer raised when one animation loops
  39208. */
  39209. onAnimationLoopObservable: Observable<TargetedAnimation>;
  39210. /**
  39211. * Observer raised when all animations have looped
  39212. */
  39213. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  39214. /**
  39215. * This observable will notify when all animations have ended.
  39216. */
  39217. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  39218. /**
  39219. * This observable will notify when all animations have paused.
  39220. */
  39221. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  39222. /**
  39223. * This observable will notify when all animations are playing.
  39224. */
  39225. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  39226. /**
  39227. * Gets the first frame
  39228. */
  39229. get from(): number;
  39230. /**
  39231. * Gets the last frame
  39232. */
  39233. get to(): number;
  39234. /**
  39235. * Define if the animations are started
  39236. */
  39237. get isStarted(): boolean;
  39238. /**
  39239. * Gets a value indicating that the current group is playing
  39240. */
  39241. get isPlaying(): boolean;
  39242. /**
  39243. * Gets or sets the speed ratio to use for all animations
  39244. */
  39245. get speedRatio(): number;
  39246. /**
  39247. * Gets or sets the speed ratio to use for all animations
  39248. */
  39249. set speedRatio(value: number);
  39250. /**
  39251. * Gets or sets if all animations should loop or not
  39252. */
  39253. get loopAnimation(): boolean;
  39254. set loopAnimation(value: boolean);
  39255. /**
  39256. * Gets or sets if all animations should be evaluated additively
  39257. */
  39258. get isAdditive(): boolean;
  39259. set isAdditive(value: boolean);
  39260. /**
  39261. * Gets the targeted animations for this animation group
  39262. */
  39263. get targetedAnimations(): Array<TargetedAnimation>;
  39264. /**
  39265. * returning the list of animatables controlled by this animation group.
  39266. */
  39267. get animatables(): Array<Animatable>;
  39268. /**
  39269. * Gets the list of target animations
  39270. */
  39271. get children(): TargetedAnimation[];
  39272. /**
  39273. * Instantiates a new Animation Group.
  39274. * This helps managing several animations at once.
  39275. * @see https://doc.babylonjs.com/how_to/group
  39276. * @param name Defines the name of the group
  39277. * @param scene Defines the scene the group belongs to
  39278. */
  39279. constructor(
  39280. /** The name of the animation group */
  39281. name: string, scene?: Nullable<Scene>);
  39282. /**
  39283. * Add an animation (with its target) in the group
  39284. * @param animation defines the animation we want to add
  39285. * @param target defines the target of the animation
  39286. * @returns the TargetedAnimation object
  39287. */
  39288. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  39289. /**
  39290. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  39291. * It can add constant keys at begin or end
  39292. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  39293. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  39294. * @returns the animation group
  39295. */
  39296. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  39297. private _animationLoopCount;
  39298. private _animationLoopFlags;
  39299. private _processLoop;
  39300. /**
  39301. * Start all animations on given targets
  39302. * @param loop defines if animations must loop
  39303. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  39304. * @param from defines the from key (optional)
  39305. * @param to defines the to key (optional)
  39306. * @param isAdditive defines the additive state for the resulting animatables (optional)
  39307. * @returns the current animation group
  39308. */
  39309. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  39310. /**
  39311. * Pause all animations
  39312. * @returns the animation group
  39313. */
  39314. pause(): AnimationGroup;
  39315. /**
  39316. * Play all animations to initial state
  39317. * This function will start() the animations if they were not started or will restart() them if they were paused
  39318. * @param loop defines if animations must loop
  39319. * @returns the animation group
  39320. */
  39321. play(loop?: boolean): AnimationGroup;
  39322. /**
  39323. * Reset all animations to initial state
  39324. * @returns the animation group
  39325. */
  39326. reset(): AnimationGroup;
  39327. /**
  39328. * Restart animations from key 0
  39329. * @returns the animation group
  39330. */
  39331. restart(): AnimationGroup;
  39332. /**
  39333. * Stop all animations
  39334. * @returns the animation group
  39335. */
  39336. stop(): AnimationGroup;
  39337. /**
  39338. * Set animation weight for all animatables
  39339. * @param weight defines the weight to use
  39340. * @return the animationGroup
  39341. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39342. */
  39343. setWeightForAllAnimatables(weight: number): AnimationGroup;
  39344. /**
  39345. * Synchronize and normalize all animatables with a source animatable
  39346. * @param root defines the root animatable to synchronize with
  39347. * @return the animationGroup
  39348. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39349. */
  39350. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  39351. /**
  39352. * Goes to a specific frame in this animation group
  39353. * @param frame the frame number to go to
  39354. * @return the animationGroup
  39355. */
  39356. goToFrame(frame: number): AnimationGroup;
  39357. /**
  39358. * Dispose all associated resources
  39359. */
  39360. dispose(): void;
  39361. private _checkAnimationGroupEnded;
  39362. /**
  39363. * Clone the current animation group and returns a copy
  39364. * @param newName defines the name of the new group
  39365. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  39366. * @returns the new aniamtion group
  39367. */
  39368. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  39369. /**
  39370. * Serializes the animationGroup to an object
  39371. * @returns Serialized object
  39372. */
  39373. serialize(): any;
  39374. /**
  39375. * Returns a new AnimationGroup object parsed from the source provided.
  39376. * @param parsedAnimationGroup defines the source
  39377. * @param scene defines the scene that will receive the animationGroup
  39378. * @returns a new AnimationGroup
  39379. */
  39380. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  39381. /**
  39382. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  39383. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  39384. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  39385. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  39386. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  39387. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  39388. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  39389. */
  39390. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  39391. /**
  39392. * Returns the string "AnimationGroup"
  39393. * @returns "AnimationGroup"
  39394. */
  39395. getClassName(): string;
  39396. /**
  39397. * Creates a detailled string about the object
  39398. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  39399. * @returns a string representing the object
  39400. */
  39401. toString(fullDetails?: boolean): string;
  39402. }
  39403. }
  39404. declare module BABYLON {
  39405. /**
  39406. * Define an interface for all classes that will hold resources
  39407. */
  39408. export interface IDisposable {
  39409. /**
  39410. * Releases all held resources
  39411. */
  39412. dispose(): void;
  39413. }
  39414. /** Interface defining initialization parameters for Scene class */
  39415. export interface SceneOptions {
  39416. /**
  39417. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  39418. * It will improve performance when the number of geometries becomes important.
  39419. */
  39420. useGeometryUniqueIdsMap?: boolean;
  39421. /**
  39422. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  39423. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39424. */
  39425. useMaterialMeshMap?: boolean;
  39426. /**
  39427. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  39428. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39429. */
  39430. useClonedMeshMap?: boolean;
  39431. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  39432. virtual?: boolean;
  39433. }
  39434. /**
  39435. * Represents a scene to be rendered by the engine.
  39436. * @see https://doc.babylonjs.com/features/scene
  39437. */
  39438. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  39439. /** The fog is deactivated */
  39440. static readonly FOGMODE_NONE: number;
  39441. /** The fog density is following an exponential function */
  39442. static readonly FOGMODE_EXP: number;
  39443. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  39444. static readonly FOGMODE_EXP2: number;
  39445. /** The fog density is following a linear function. */
  39446. static readonly FOGMODE_LINEAR: number;
  39447. /**
  39448. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  39449. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39450. */
  39451. static MinDeltaTime: number;
  39452. /**
  39453. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  39454. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39455. */
  39456. static MaxDeltaTime: number;
  39457. /**
  39458. * Factory used to create the default material.
  39459. * @param name The name of the material to create
  39460. * @param scene The scene to create the material for
  39461. * @returns The default material
  39462. */
  39463. static DefaultMaterialFactory(scene: Scene): Material;
  39464. /**
  39465. * Factory used to create the a collision coordinator.
  39466. * @returns The collision coordinator
  39467. */
  39468. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  39469. /** @hidden */
  39470. _inputManager: InputManager;
  39471. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  39472. cameraToUseForPointers: Nullable<Camera>;
  39473. /** @hidden */
  39474. readonly _isScene: boolean;
  39475. /** @hidden */
  39476. _blockEntityCollection: boolean;
  39477. /**
  39478. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  39479. */
  39480. autoClear: boolean;
  39481. /**
  39482. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  39483. */
  39484. autoClearDepthAndStencil: boolean;
  39485. /**
  39486. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  39487. */
  39488. clearColor: Color4;
  39489. /**
  39490. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  39491. */
  39492. ambientColor: Color3;
  39493. /**
  39494. * This is use to store the default BRDF lookup for PBR materials in your scene.
  39495. * It should only be one of the following (if not the default embedded one):
  39496. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  39497. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  39498. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  39499. * The material properties need to be setup according to the type of texture in use.
  39500. */
  39501. environmentBRDFTexture: BaseTexture;
  39502. /**
  39503. * Texture used in all pbr material as the reflection texture.
  39504. * As in the majority of the scene they are the same (exception for multi room and so on),
  39505. * this is easier to reference from here than from all the materials.
  39506. */
  39507. get environmentTexture(): Nullable<BaseTexture>;
  39508. /**
  39509. * Texture used in all pbr material as the reflection texture.
  39510. * As in the majority of the scene they are the same (exception for multi room and so on),
  39511. * this is easier to set here than in all the materials.
  39512. */
  39513. set environmentTexture(value: Nullable<BaseTexture>);
  39514. /** @hidden */
  39515. protected _environmentIntensity: number;
  39516. /**
  39517. * Intensity of the environment in all pbr material.
  39518. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39519. * As in the majority of the scene they are the same (exception for multi room and so on),
  39520. * this is easier to reference from here than from all the materials.
  39521. */
  39522. get environmentIntensity(): number;
  39523. /**
  39524. * Intensity of the environment in all pbr material.
  39525. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39526. * As in the majority of the scene they are the same (exception for multi room and so on),
  39527. * this is easier to set here than in all the materials.
  39528. */
  39529. set environmentIntensity(value: number);
  39530. /** @hidden */
  39531. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39532. /**
  39533. * Default image processing configuration used either in the rendering
  39534. * Forward main pass or through the imageProcessingPostProcess if present.
  39535. * As in the majority of the scene they are the same (exception for multi camera),
  39536. * this is easier to reference from here than from all the materials and post process.
  39537. *
  39538. * No setter as we it is a shared configuration, you can set the values instead.
  39539. */
  39540. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  39541. private _forceWireframe;
  39542. /**
  39543. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  39544. */
  39545. set forceWireframe(value: boolean);
  39546. get forceWireframe(): boolean;
  39547. private _skipFrustumClipping;
  39548. /**
  39549. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  39550. */
  39551. set skipFrustumClipping(value: boolean);
  39552. get skipFrustumClipping(): boolean;
  39553. private _forcePointsCloud;
  39554. /**
  39555. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  39556. */
  39557. set forcePointsCloud(value: boolean);
  39558. get forcePointsCloud(): boolean;
  39559. /**
  39560. * Gets or sets the active clipplane 1
  39561. */
  39562. clipPlane: Nullable<Plane>;
  39563. /**
  39564. * Gets or sets the active clipplane 2
  39565. */
  39566. clipPlane2: Nullable<Plane>;
  39567. /**
  39568. * Gets or sets the active clipplane 3
  39569. */
  39570. clipPlane3: Nullable<Plane>;
  39571. /**
  39572. * Gets or sets the active clipplane 4
  39573. */
  39574. clipPlane4: Nullable<Plane>;
  39575. /**
  39576. * Gets or sets the active clipplane 5
  39577. */
  39578. clipPlane5: Nullable<Plane>;
  39579. /**
  39580. * Gets or sets the active clipplane 6
  39581. */
  39582. clipPlane6: Nullable<Plane>;
  39583. /**
  39584. * Gets or sets a boolean indicating if animations are enabled
  39585. */
  39586. animationsEnabled: boolean;
  39587. private _animationPropertiesOverride;
  39588. /**
  39589. * Gets or sets the animation properties override
  39590. */
  39591. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  39592. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  39593. /**
  39594. * Gets or sets a boolean indicating if a constant deltatime has to be used
  39595. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  39596. */
  39597. useConstantAnimationDeltaTime: boolean;
  39598. /**
  39599. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  39600. * Please note that it requires to run a ray cast through the scene on every frame
  39601. */
  39602. constantlyUpdateMeshUnderPointer: boolean;
  39603. /**
  39604. * Defines the HTML cursor to use when hovering over interactive elements
  39605. */
  39606. hoverCursor: string;
  39607. /**
  39608. * Defines the HTML default cursor to use (empty by default)
  39609. */
  39610. defaultCursor: string;
  39611. /**
  39612. * Defines whether cursors are handled by the scene.
  39613. */
  39614. doNotHandleCursors: boolean;
  39615. /**
  39616. * This is used to call preventDefault() on pointer down
  39617. * in order to block unwanted artifacts like system double clicks
  39618. */
  39619. preventDefaultOnPointerDown: boolean;
  39620. /**
  39621. * This is used to call preventDefault() on pointer up
  39622. * in order to block unwanted artifacts like system double clicks
  39623. */
  39624. preventDefaultOnPointerUp: boolean;
  39625. /**
  39626. * Gets or sets user defined metadata
  39627. */
  39628. metadata: any;
  39629. /**
  39630. * For internal use only. Please do not use.
  39631. */
  39632. reservedDataStore: any;
  39633. /**
  39634. * Gets the name of the plugin used to load this scene (null by default)
  39635. */
  39636. loadingPluginName: string;
  39637. /**
  39638. * Use this array to add regular expressions used to disable offline support for specific urls
  39639. */
  39640. disableOfflineSupportExceptionRules: RegExp[];
  39641. /**
  39642. * An event triggered when the scene is disposed.
  39643. */
  39644. onDisposeObservable: Observable<Scene>;
  39645. private _onDisposeObserver;
  39646. /** Sets a function to be executed when this scene is disposed. */
  39647. set onDispose(callback: () => void);
  39648. /**
  39649. * An event triggered before rendering the scene (right after animations and physics)
  39650. */
  39651. onBeforeRenderObservable: Observable<Scene>;
  39652. private _onBeforeRenderObserver;
  39653. /** Sets a function to be executed before rendering this scene */
  39654. set beforeRender(callback: Nullable<() => void>);
  39655. /**
  39656. * An event triggered after rendering the scene
  39657. */
  39658. onAfterRenderObservable: Observable<Scene>;
  39659. /**
  39660. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  39661. */
  39662. onAfterRenderCameraObservable: Observable<Camera>;
  39663. private _onAfterRenderObserver;
  39664. /** Sets a function to be executed after rendering this scene */
  39665. set afterRender(callback: Nullable<() => void>);
  39666. /**
  39667. * An event triggered before animating the scene
  39668. */
  39669. onBeforeAnimationsObservable: Observable<Scene>;
  39670. /**
  39671. * An event triggered after animations processing
  39672. */
  39673. onAfterAnimationsObservable: Observable<Scene>;
  39674. /**
  39675. * An event triggered before draw calls are ready to be sent
  39676. */
  39677. onBeforeDrawPhaseObservable: Observable<Scene>;
  39678. /**
  39679. * An event triggered after draw calls have been sent
  39680. */
  39681. onAfterDrawPhaseObservable: Observable<Scene>;
  39682. /**
  39683. * An event triggered when the scene is ready
  39684. */
  39685. onReadyObservable: Observable<Scene>;
  39686. /**
  39687. * An event triggered before rendering a camera
  39688. */
  39689. onBeforeCameraRenderObservable: Observable<Camera>;
  39690. private _onBeforeCameraRenderObserver;
  39691. /** Sets a function to be executed before rendering a camera*/
  39692. set beforeCameraRender(callback: () => void);
  39693. /**
  39694. * An event triggered after rendering a camera
  39695. */
  39696. onAfterCameraRenderObservable: Observable<Camera>;
  39697. private _onAfterCameraRenderObserver;
  39698. /** Sets a function to be executed after rendering a camera*/
  39699. set afterCameraRender(callback: () => void);
  39700. /**
  39701. * An event triggered when active meshes evaluation is about to start
  39702. */
  39703. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  39704. /**
  39705. * An event triggered when active meshes evaluation is done
  39706. */
  39707. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  39708. /**
  39709. * An event triggered when particles rendering is about to start
  39710. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39711. */
  39712. onBeforeParticlesRenderingObservable: Observable<Scene>;
  39713. /**
  39714. * An event triggered when particles rendering is done
  39715. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39716. */
  39717. onAfterParticlesRenderingObservable: Observable<Scene>;
  39718. /**
  39719. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  39720. */
  39721. onDataLoadedObservable: Observable<Scene>;
  39722. /**
  39723. * An event triggered when a camera is created
  39724. */
  39725. onNewCameraAddedObservable: Observable<Camera>;
  39726. /**
  39727. * An event triggered when a camera is removed
  39728. */
  39729. onCameraRemovedObservable: Observable<Camera>;
  39730. /**
  39731. * An event triggered when a light is created
  39732. */
  39733. onNewLightAddedObservable: Observable<Light>;
  39734. /**
  39735. * An event triggered when a light is removed
  39736. */
  39737. onLightRemovedObservable: Observable<Light>;
  39738. /**
  39739. * An event triggered when a geometry is created
  39740. */
  39741. onNewGeometryAddedObservable: Observable<Geometry>;
  39742. /**
  39743. * An event triggered when a geometry is removed
  39744. */
  39745. onGeometryRemovedObservable: Observable<Geometry>;
  39746. /**
  39747. * An event triggered when a transform node is created
  39748. */
  39749. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  39750. /**
  39751. * An event triggered when a transform node is removed
  39752. */
  39753. onTransformNodeRemovedObservable: Observable<TransformNode>;
  39754. /**
  39755. * An event triggered when a mesh is created
  39756. */
  39757. onNewMeshAddedObservable: Observable<AbstractMesh>;
  39758. /**
  39759. * An event triggered when a mesh is removed
  39760. */
  39761. onMeshRemovedObservable: Observable<AbstractMesh>;
  39762. /**
  39763. * An event triggered when a skeleton is created
  39764. */
  39765. onNewSkeletonAddedObservable: Observable<Skeleton>;
  39766. /**
  39767. * An event triggered when a skeleton is removed
  39768. */
  39769. onSkeletonRemovedObservable: Observable<Skeleton>;
  39770. /**
  39771. * An event triggered when a material is created
  39772. */
  39773. onNewMaterialAddedObservable: Observable<Material>;
  39774. /**
  39775. * An event triggered when a material is removed
  39776. */
  39777. onMaterialRemovedObservable: Observable<Material>;
  39778. /**
  39779. * An event triggered when a texture is created
  39780. */
  39781. onNewTextureAddedObservable: Observable<BaseTexture>;
  39782. /**
  39783. * An event triggered when a texture is removed
  39784. */
  39785. onTextureRemovedObservable: Observable<BaseTexture>;
  39786. /**
  39787. * An event triggered when render targets are about to be rendered
  39788. * Can happen multiple times per frame.
  39789. */
  39790. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  39791. /**
  39792. * An event triggered when render targets were rendered.
  39793. * Can happen multiple times per frame.
  39794. */
  39795. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  39796. /**
  39797. * An event triggered before calculating deterministic simulation step
  39798. */
  39799. onBeforeStepObservable: Observable<Scene>;
  39800. /**
  39801. * An event triggered after calculating deterministic simulation step
  39802. */
  39803. onAfterStepObservable: Observable<Scene>;
  39804. /**
  39805. * An event triggered when the activeCamera property is updated
  39806. */
  39807. onActiveCameraChanged: Observable<Scene>;
  39808. /**
  39809. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  39810. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39811. * 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)
  39812. */
  39813. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39814. /**
  39815. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  39816. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39817. * 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)
  39818. */
  39819. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39820. /**
  39821. * This Observable will when a mesh has been imported into the scene.
  39822. */
  39823. onMeshImportedObservable: Observable<AbstractMesh>;
  39824. /**
  39825. * This Observable will when an animation file has been imported into the scene.
  39826. */
  39827. onAnimationFileImportedObservable: Observable<Scene>;
  39828. /**
  39829. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  39830. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  39831. */
  39832. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  39833. /** @hidden */
  39834. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  39835. /**
  39836. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  39837. */
  39838. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  39839. /**
  39840. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  39841. */
  39842. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  39843. /**
  39844. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  39845. */
  39846. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  39847. /** Callback called when a pointer move is detected */
  39848. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39849. /** Callback called when a pointer down is detected */
  39850. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39851. /** Callback called when a pointer up is detected */
  39852. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  39853. /** Callback called when a pointer pick is detected */
  39854. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  39855. /**
  39856. * 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).
  39857. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  39858. */
  39859. onPrePointerObservable: Observable<PointerInfoPre>;
  39860. /**
  39861. * Observable event triggered each time an input event is received from the rendering canvas
  39862. */
  39863. onPointerObservable: Observable<PointerInfo>;
  39864. /**
  39865. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  39866. */
  39867. get unTranslatedPointer(): Vector2;
  39868. /**
  39869. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  39870. */
  39871. static get DragMovementThreshold(): number;
  39872. static set DragMovementThreshold(value: number);
  39873. /**
  39874. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  39875. */
  39876. static get LongPressDelay(): number;
  39877. static set LongPressDelay(value: number);
  39878. /**
  39879. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  39880. */
  39881. static get DoubleClickDelay(): number;
  39882. static set DoubleClickDelay(value: number);
  39883. /** If you need to check double click without raising a single click at first click, enable this flag */
  39884. static get ExclusiveDoubleClickMode(): boolean;
  39885. static set ExclusiveDoubleClickMode(value: boolean);
  39886. /** @hidden */
  39887. _mirroredCameraPosition: Nullable<Vector3>;
  39888. /**
  39889. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  39890. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  39891. */
  39892. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  39893. /**
  39894. * Observable event triggered each time an keyboard event is received from the hosting window
  39895. */
  39896. onKeyboardObservable: Observable<KeyboardInfo>;
  39897. private _useRightHandedSystem;
  39898. /**
  39899. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  39900. */
  39901. set useRightHandedSystem(value: boolean);
  39902. get useRightHandedSystem(): boolean;
  39903. private _timeAccumulator;
  39904. private _currentStepId;
  39905. private _currentInternalStep;
  39906. /**
  39907. * Sets the step Id used by deterministic lock step
  39908. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39909. * @param newStepId defines the step Id
  39910. */
  39911. setStepId(newStepId: number): void;
  39912. /**
  39913. * Gets the step Id used by deterministic lock step
  39914. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39915. * @returns the step Id
  39916. */
  39917. getStepId(): number;
  39918. /**
  39919. * Gets the internal step used by deterministic lock step
  39920. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39921. * @returns the internal step
  39922. */
  39923. getInternalStep(): number;
  39924. private _fogEnabled;
  39925. /**
  39926. * Gets or sets a boolean indicating if fog is enabled on this scene
  39927. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39928. * (Default is true)
  39929. */
  39930. set fogEnabled(value: boolean);
  39931. get fogEnabled(): boolean;
  39932. private _fogMode;
  39933. /**
  39934. * Gets or sets the fog mode to use
  39935. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39936. * | mode | value |
  39937. * | --- | --- |
  39938. * | FOGMODE_NONE | 0 |
  39939. * | FOGMODE_EXP | 1 |
  39940. * | FOGMODE_EXP2 | 2 |
  39941. * | FOGMODE_LINEAR | 3 |
  39942. */
  39943. set fogMode(value: number);
  39944. get fogMode(): number;
  39945. /**
  39946. * Gets or sets the fog color to use
  39947. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39948. * (Default is Color3(0.2, 0.2, 0.3))
  39949. */
  39950. fogColor: Color3;
  39951. /**
  39952. * Gets or sets the fog density to use
  39953. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39954. * (Default is 0.1)
  39955. */
  39956. fogDensity: number;
  39957. /**
  39958. * Gets or sets the fog start distance to use
  39959. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39960. * (Default is 0)
  39961. */
  39962. fogStart: number;
  39963. /**
  39964. * Gets or sets the fog end distance to use
  39965. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39966. * (Default is 1000)
  39967. */
  39968. fogEnd: number;
  39969. /**
  39970. * Flag indicating that the frame buffer binding is handled by another component
  39971. */
  39972. prePass: boolean;
  39973. private _shadowsEnabled;
  39974. /**
  39975. * Gets or sets a boolean indicating if shadows are enabled on this scene
  39976. */
  39977. set shadowsEnabled(value: boolean);
  39978. get shadowsEnabled(): boolean;
  39979. private _lightsEnabled;
  39980. /**
  39981. * Gets or sets a boolean indicating if lights are enabled on this scene
  39982. */
  39983. set lightsEnabled(value: boolean);
  39984. get lightsEnabled(): boolean;
  39985. /** All of the active cameras added to this scene. */
  39986. activeCameras: Camera[];
  39987. /** @hidden */
  39988. _activeCamera: Nullable<Camera>;
  39989. /** Gets or sets the current active camera */
  39990. get activeCamera(): Nullable<Camera>;
  39991. set activeCamera(value: Nullable<Camera>);
  39992. private _defaultMaterial;
  39993. /** The default material used on meshes when no material is affected */
  39994. get defaultMaterial(): Material;
  39995. /** The default material used on meshes when no material is affected */
  39996. set defaultMaterial(value: Material);
  39997. private _texturesEnabled;
  39998. /**
  39999. * Gets or sets a boolean indicating if textures are enabled on this scene
  40000. */
  40001. set texturesEnabled(value: boolean);
  40002. get texturesEnabled(): boolean;
  40003. /**
  40004. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  40005. */
  40006. physicsEnabled: boolean;
  40007. /**
  40008. * Gets or sets a boolean indicating if particles are enabled on this scene
  40009. */
  40010. particlesEnabled: boolean;
  40011. /**
  40012. * Gets or sets a boolean indicating if sprites are enabled on this scene
  40013. */
  40014. spritesEnabled: boolean;
  40015. private _skeletonsEnabled;
  40016. /**
  40017. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  40018. */
  40019. set skeletonsEnabled(value: boolean);
  40020. get skeletonsEnabled(): boolean;
  40021. /**
  40022. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  40023. */
  40024. lensFlaresEnabled: boolean;
  40025. /**
  40026. * Gets or sets a boolean indicating if collisions are enabled on this scene
  40027. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  40028. */
  40029. collisionsEnabled: boolean;
  40030. private _collisionCoordinator;
  40031. /** @hidden */
  40032. get collisionCoordinator(): ICollisionCoordinator;
  40033. /**
  40034. * Defines the gravity applied to this scene (used only for collisions)
  40035. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  40036. */
  40037. gravity: Vector3;
  40038. /**
  40039. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  40040. */
  40041. postProcessesEnabled: boolean;
  40042. /**
  40043. * Gets the current postprocess manager
  40044. */
  40045. postProcessManager: PostProcessManager;
  40046. /**
  40047. * Gets or sets a boolean indicating if render targets are enabled on this scene
  40048. */
  40049. renderTargetsEnabled: boolean;
  40050. /**
  40051. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  40052. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  40053. */
  40054. dumpNextRenderTargets: boolean;
  40055. /**
  40056. * The list of user defined render targets added to the scene
  40057. */
  40058. customRenderTargets: RenderTargetTexture[];
  40059. /**
  40060. * Defines if texture loading must be delayed
  40061. * If true, textures will only be loaded when they need to be rendered
  40062. */
  40063. useDelayedTextureLoading: boolean;
  40064. /**
  40065. * Gets the list of meshes imported to the scene through SceneLoader
  40066. */
  40067. importedMeshesFiles: String[];
  40068. /**
  40069. * Gets or sets a boolean indicating if probes are enabled on this scene
  40070. */
  40071. probesEnabled: boolean;
  40072. /**
  40073. * Gets or sets the current offline provider to use to store scene data
  40074. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  40075. */
  40076. offlineProvider: IOfflineProvider;
  40077. /**
  40078. * Gets or sets the action manager associated with the scene
  40079. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  40080. */
  40081. actionManager: AbstractActionManager;
  40082. private _meshesForIntersections;
  40083. /**
  40084. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  40085. */
  40086. proceduralTexturesEnabled: boolean;
  40087. private _engine;
  40088. private _totalVertices;
  40089. /** @hidden */
  40090. _activeIndices: PerfCounter;
  40091. /** @hidden */
  40092. _activeParticles: PerfCounter;
  40093. /** @hidden */
  40094. _activeBones: PerfCounter;
  40095. private _animationRatio;
  40096. /** @hidden */
  40097. _animationTimeLast: number;
  40098. /** @hidden */
  40099. _animationTime: number;
  40100. /**
  40101. * Gets or sets a general scale for animation speed
  40102. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  40103. */
  40104. animationTimeScale: number;
  40105. /** @hidden */
  40106. _cachedMaterial: Nullable<Material>;
  40107. /** @hidden */
  40108. _cachedEffect: Nullable<Effect>;
  40109. /** @hidden */
  40110. _cachedVisibility: Nullable<number>;
  40111. private _renderId;
  40112. private _frameId;
  40113. private _executeWhenReadyTimeoutId;
  40114. private _intermediateRendering;
  40115. private _viewUpdateFlag;
  40116. private _projectionUpdateFlag;
  40117. /** @hidden */
  40118. _toBeDisposed: Nullable<IDisposable>[];
  40119. private _activeRequests;
  40120. /** @hidden */
  40121. _pendingData: any[];
  40122. private _isDisposed;
  40123. /**
  40124. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  40125. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  40126. */
  40127. dispatchAllSubMeshesOfActiveMeshes: boolean;
  40128. private _activeMeshes;
  40129. private _processedMaterials;
  40130. private _renderTargets;
  40131. /** @hidden */
  40132. _activeParticleSystems: SmartArray<IParticleSystem>;
  40133. private _activeSkeletons;
  40134. private _softwareSkinnedMeshes;
  40135. private _renderingManager;
  40136. /** @hidden */
  40137. _activeAnimatables: Animatable[];
  40138. private _transformMatrix;
  40139. private _sceneUbo;
  40140. /** @hidden */
  40141. _viewMatrix: Matrix;
  40142. private _projectionMatrix;
  40143. /** @hidden */
  40144. _forcedViewPosition: Nullable<Vector3>;
  40145. /** @hidden */
  40146. _frustumPlanes: Plane[];
  40147. /**
  40148. * Gets the list of frustum planes (built from the active camera)
  40149. */
  40150. get frustumPlanes(): Plane[];
  40151. /**
  40152. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  40153. * This is useful if there are more lights that the maximum simulteanous authorized
  40154. */
  40155. requireLightSorting: boolean;
  40156. /** @hidden */
  40157. readonly useMaterialMeshMap: boolean;
  40158. /** @hidden */
  40159. readonly useClonedMeshMap: boolean;
  40160. private _externalData;
  40161. private _uid;
  40162. /**
  40163. * @hidden
  40164. * Backing store of defined scene components.
  40165. */
  40166. _components: ISceneComponent[];
  40167. /**
  40168. * @hidden
  40169. * Backing store of defined scene components.
  40170. */
  40171. _serializableComponents: ISceneSerializableComponent[];
  40172. /**
  40173. * List of components to register on the next registration step.
  40174. */
  40175. private _transientComponents;
  40176. /**
  40177. * Registers the transient components if needed.
  40178. */
  40179. private _registerTransientComponents;
  40180. /**
  40181. * @hidden
  40182. * Add a component to the scene.
  40183. * Note that the ccomponent could be registered on th next frame if this is called after
  40184. * the register component stage.
  40185. * @param component Defines the component to add to the scene
  40186. */
  40187. _addComponent(component: ISceneComponent): void;
  40188. /**
  40189. * @hidden
  40190. * Gets a component from the scene.
  40191. * @param name defines the name of the component to retrieve
  40192. * @returns the component or null if not present
  40193. */
  40194. _getComponent(name: string): Nullable<ISceneComponent>;
  40195. /**
  40196. * @hidden
  40197. * Defines the actions happening before camera updates.
  40198. */
  40199. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  40200. /**
  40201. * @hidden
  40202. * Defines the actions happening before clear the canvas.
  40203. */
  40204. _beforeClearStage: Stage<SimpleStageAction>;
  40205. /**
  40206. * @hidden
  40207. * Defines the actions when collecting render targets for the frame.
  40208. */
  40209. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40210. /**
  40211. * @hidden
  40212. * Defines the actions happening for one camera in the frame.
  40213. */
  40214. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40215. /**
  40216. * @hidden
  40217. * Defines the actions happening during the per mesh ready checks.
  40218. */
  40219. _isReadyForMeshStage: Stage<MeshStageAction>;
  40220. /**
  40221. * @hidden
  40222. * Defines the actions happening before evaluate active mesh checks.
  40223. */
  40224. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  40225. /**
  40226. * @hidden
  40227. * Defines the actions happening during the evaluate sub mesh checks.
  40228. */
  40229. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  40230. /**
  40231. * @hidden
  40232. * Defines the actions happening during the active mesh stage.
  40233. */
  40234. _activeMeshStage: Stage<ActiveMeshStageAction>;
  40235. /**
  40236. * @hidden
  40237. * Defines the actions happening during the per camera render target step.
  40238. */
  40239. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  40240. /**
  40241. * @hidden
  40242. * Defines the actions happening just before the active camera is drawing.
  40243. */
  40244. _beforeCameraDrawStage: Stage<CameraStageAction>;
  40245. /**
  40246. * @hidden
  40247. * Defines the actions happening just before a render target is drawing.
  40248. */
  40249. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40250. /**
  40251. * @hidden
  40252. * Defines the actions happening just before a rendering group is drawing.
  40253. */
  40254. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40255. /**
  40256. * @hidden
  40257. * Defines the actions happening just before a mesh is drawing.
  40258. */
  40259. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40260. /**
  40261. * @hidden
  40262. * Defines the actions happening just after a mesh has been drawn.
  40263. */
  40264. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40265. /**
  40266. * @hidden
  40267. * Defines the actions happening just after a rendering group has been drawn.
  40268. */
  40269. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40270. /**
  40271. * @hidden
  40272. * Defines the actions happening just after the active camera has been drawn.
  40273. */
  40274. _afterCameraDrawStage: Stage<CameraStageAction>;
  40275. /**
  40276. * @hidden
  40277. * Defines the actions happening just after a render target has been drawn.
  40278. */
  40279. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40280. /**
  40281. * @hidden
  40282. * Defines the actions happening just after rendering all cameras and computing intersections.
  40283. */
  40284. _afterRenderStage: Stage<SimpleStageAction>;
  40285. /**
  40286. * @hidden
  40287. * Defines the actions happening when a pointer move event happens.
  40288. */
  40289. _pointerMoveStage: Stage<PointerMoveStageAction>;
  40290. /**
  40291. * @hidden
  40292. * Defines the actions happening when a pointer down event happens.
  40293. */
  40294. _pointerDownStage: Stage<PointerUpDownStageAction>;
  40295. /**
  40296. * @hidden
  40297. * Defines the actions happening when a pointer up event happens.
  40298. */
  40299. _pointerUpStage: Stage<PointerUpDownStageAction>;
  40300. /**
  40301. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  40302. */
  40303. private geometriesByUniqueId;
  40304. /**
  40305. * Creates a new Scene
  40306. * @param engine defines the engine to use to render this scene
  40307. * @param options defines the scene options
  40308. */
  40309. constructor(engine: Engine, options?: SceneOptions);
  40310. /**
  40311. * Gets a string identifying the name of the class
  40312. * @returns "Scene" string
  40313. */
  40314. getClassName(): string;
  40315. private _defaultMeshCandidates;
  40316. /**
  40317. * @hidden
  40318. */
  40319. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40320. private _defaultSubMeshCandidates;
  40321. /**
  40322. * @hidden
  40323. */
  40324. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40325. /**
  40326. * Sets the default candidate providers for the scene.
  40327. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  40328. * and getCollidingSubMeshCandidates to their default function
  40329. */
  40330. setDefaultCandidateProviders(): void;
  40331. /**
  40332. * Gets the mesh that is currently under the pointer
  40333. */
  40334. get meshUnderPointer(): Nullable<AbstractMesh>;
  40335. /**
  40336. * Gets or sets the current on-screen X position of the pointer
  40337. */
  40338. get pointerX(): number;
  40339. set pointerX(value: number);
  40340. /**
  40341. * Gets or sets the current on-screen Y position of the pointer
  40342. */
  40343. get pointerY(): number;
  40344. set pointerY(value: number);
  40345. /**
  40346. * Gets the cached material (ie. the latest rendered one)
  40347. * @returns the cached material
  40348. */
  40349. getCachedMaterial(): Nullable<Material>;
  40350. /**
  40351. * Gets the cached effect (ie. the latest rendered one)
  40352. * @returns the cached effect
  40353. */
  40354. getCachedEffect(): Nullable<Effect>;
  40355. /**
  40356. * Gets the cached visibility state (ie. the latest rendered one)
  40357. * @returns the cached visibility state
  40358. */
  40359. getCachedVisibility(): Nullable<number>;
  40360. /**
  40361. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  40362. * @param material defines the current material
  40363. * @param effect defines the current effect
  40364. * @param visibility defines the current visibility state
  40365. * @returns true if one parameter is not cached
  40366. */
  40367. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  40368. /**
  40369. * Gets the engine associated with the scene
  40370. * @returns an Engine
  40371. */
  40372. getEngine(): Engine;
  40373. /**
  40374. * Gets the total number of vertices rendered per frame
  40375. * @returns the total number of vertices rendered per frame
  40376. */
  40377. getTotalVertices(): number;
  40378. /**
  40379. * Gets the performance counter for total vertices
  40380. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40381. */
  40382. get totalVerticesPerfCounter(): PerfCounter;
  40383. /**
  40384. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  40385. * @returns the total number of active indices rendered per frame
  40386. */
  40387. getActiveIndices(): number;
  40388. /**
  40389. * Gets the performance counter for active indices
  40390. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40391. */
  40392. get totalActiveIndicesPerfCounter(): PerfCounter;
  40393. /**
  40394. * Gets the total number of active particles rendered per frame
  40395. * @returns the total number of active particles rendered per frame
  40396. */
  40397. getActiveParticles(): number;
  40398. /**
  40399. * Gets the performance counter for active particles
  40400. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40401. */
  40402. get activeParticlesPerfCounter(): PerfCounter;
  40403. /**
  40404. * Gets the total number of active bones rendered per frame
  40405. * @returns the total number of active bones rendered per frame
  40406. */
  40407. getActiveBones(): number;
  40408. /**
  40409. * Gets the performance counter for active bones
  40410. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40411. */
  40412. get activeBonesPerfCounter(): PerfCounter;
  40413. /**
  40414. * Gets the array of active meshes
  40415. * @returns an array of AbstractMesh
  40416. */
  40417. getActiveMeshes(): SmartArray<AbstractMesh>;
  40418. /**
  40419. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  40420. * @returns a number
  40421. */
  40422. getAnimationRatio(): number;
  40423. /**
  40424. * Gets an unique Id for the current render phase
  40425. * @returns a number
  40426. */
  40427. getRenderId(): number;
  40428. /**
  40429. * Gets an unique Id for the current frame
  40430. * @returns a number
  40431. */
  40432. getFrameId(): number;
  40433. /** Call this function if you want to manually increment the render Id*/
  40434. incrementRenderId(): void;
  40435. private _createUbo;
  40436. /**
  40437. * Use this method to simulate a pointer move on a mesh
  40438. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40439. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40440. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40441. * @returns the current scene
  40442. */
  40443. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40444. /**
  40445. * Use this method to simulate a pointer down on a mesh
  40446. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40447. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40448. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40449. * @returns the current scene
  40450. */
  40451. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40452. /**
  40453. * Use this method to simulate a pointer up on a mesh
  40454. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40455. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40456. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40457. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40458. * @returns the current scene
  40459. */
  40460. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  40461. /**
  40462. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40463. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40464. * @returns true if the pointer was captured
  40465. */
  40466. isPointerCaptured(pointerId?: number): boolean;
  40467. /**
  40468. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40469. * @param attachUp defines if you want to attach events to pointerup
  40470. * @param attachDown defines if you want to attach events to pointerdown
  40471. * @param attachMove defines if you want to attach events to pointermove
  40472. */
  40473. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  40474. /** Detaches all event handlers*/
  40475. detachControl(): void;
  40476. /**
  40477. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  40478. * Delay loaded resources are not taking in account
  40479. * @return true if all required resources are ready
  40480. */
  40481. isReady(): boolean;
  40482. /** Resets all cached information relative to material (including effect and visibility) */
  40483. resetCachedMaterial(): void;
  40484. /**
  40485. * Registers a function to be called before every frame render
  40486. * @param func defines the function to register
  40487. */
  40488. registerBeforeRender(func: () => void): void;
  40489. /**
  40490. * Unregisters a function called before every frame render
  40491. * @param func defines the function to unregister
  40492. */
  40493. unregisterBeforeRender(func: () => void): void;
  40494. /**
  40495. * Registers a function to be called after every frame render
  40496. * @param func defines the function to register
  40497. */
  40498. registerAfterRender(func: () => void): void;
  40499. /**
  40500. * Unregisters a function called after every frame render
  40501. * @param func defines the function to unregister
  40502. */
  40503. unregisterAfterRender(func: () => void): void;
  40504. private _executeOnceBeforeRender;
  40505. /**
  40506. * The provided function will run before render once and will be disposed afterwards.
  40507. * A timeout delay can be provided so that the function will be executed in N ms.
  40508. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  40509. * @param func The function to be executed.
  40510. * @param timeout optional delay in ms
  40511. */
  40512. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  40513. /** @hidden */
  40514. _addPendingData(data: any): void;
  40515. /** @hidden */
  40516. _removePendingData(data: any): void;
  40517. /**
  40518. * Returns the number of items waiting to be loaded
  40519. * @returns the number of items waiting to be loaded
  40520. */
  40521. getWaitingItemsCount(): number;
  40522. /**
  40523. * Returns a boolean indicating if the scene is still loading data
  40524. */
  40525. get isLoading(): boolean;
  40526. /**
  40527. * Registers a function to be executed when the scene is ready
  40528. * @param {Function} func - the function to be executed
  40529. */
  40530. executeWhenReady(func: () => void): void;
  40531. /**
  40532. * Returns a promise that resolves when the scene is ready
  40533. * @returns A promise that resolves when the scene is ready
  40534. */
  40535. whenReadyAsync(): Promise<void>;
  40536. /** @hidden */
  40537. _checkIsReady(): void;
  40538. /**
  40539. * Gets all animatable attached to the scene
  40540. */
  40541. get animatables(): Animatable[];
  40542. /**
  40543. * Resets the last animation time frame.
  40544. * Useful to override when animations start running when loading a scene for the first time.
  40545. */
  40546. resetLastAnimationTimeFrame(): void;
  40547. /**
  40548. * Gets the current view matrix
  40549. * @returns a Matrix
  40550. */
  40551. getViewMatrix(): Matrix;
  40552. /**
  40553. * Gets the current projection matrix
  40554. * @returns a Matrix
  40555. */
  40556. getProjectionMatrix(): Matrix;
  40557. /**
  40558. * Gets the current transform matrix
  40559. * @returns a Matrix made of View * Projection
  40560. */
  40561. getTransformMatrix(): Matrix;
  40562. /**
  40563. * Sets the current transform matrix
  40564. * @param viewL defines the View matrix to use
  40565. * @param projectionL defines the Projection matrix to use
  40566. * @param viewR defines the right View matrix to use (if provided)
  40567. * @param projectionR defines the right Projection matrix to use (if provided)
  40568. */
  40569. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  40570. /**
  40571. * Gets the uniform buffer used to store scene data
  40572. * @returns a UniformBuffer
  40573. */
  40574. getSceneUniformBuffer(): UniformBuffer;
  40575. /**
  40576. * Gets an unique (relatively to the current scene) Id
  40577. * @returns an unique number for the scene
  40578. */
  40579. getUniqueId(): number;
  40580. /**
  40581. * Add a mesh to the list of scene's meshes
  40582. * @param newMesh defines the mesh to add
  40583. * @param recursive if all child meshes should also be added to the scene
  40584. */
  40585. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  40586. /**
  40587. * Remove a mesh for the list of scene's meshes
  40588. * @param toRemove defines the mesh to remove
  40589. * @param recursive if all child meshes should also be removed from the scene
  40590. * @returns the index where the mesh was in the mesh list
  40591. */
  40592. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  40593. /**
  40594. * Add a transform node to the list of scene's transform nodes
  40595. * @param newTransformNode defines the transform node to add
  40596. */
  40597. addTransformNode(newTransformNode: TransformNode): void;
  40598. /**
  40599. * Remove a transform node for the list of scene's transform nodes
  40600. * @param toRemove defines the transform node to remove
  40601. * @returns the index where the transform node was in the transform node list
  40602. */
  40603. removeTransformNode(toRemove: TransformNode): number;
  40604. /**
  40605. * Remove a skeleton for the list of scene's skeletons
  40606. * @param toRemove defines the skeleton to remove
  40607. * @returns the index where the skeleton was in the skeleton list
  40608. */
  40609. removeSkeleton(toRemove: Skeleton): number;
  40610. /**
  40611. * Remove a morph target for the list of scene's morph targets
  40612. * @param toRemove defines the morph target to remove
  40613. * @returns the index where the morph target was in the morph target list
  40614. */
  40615. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  40616. /**
  40617. * Remove a light for the list of scene's lights
  40618. * @param toRemove defines the light to remove
  40619. * @returns the index where the light was in the light list
  40620. */
  40621. removeLight(toRemove: Light): number;
  40622. /**
  40623. * Remove a camera for the list of scene's cameras
  40624. * @param toRemove defines the camera to remove
  40625. * @returns the index where the camera was in the camera list
  40626. */
  40627. removeCamera(toRemove: Camera): number;
  40628. /**
  40629. * Remove a particle system for the list of scene's particle systems
  40630. * @param toRemove defines the particle system to remove
  40631. * @returns the index where the particle system was in the particle system list
  40632. */
  40633. removeParticleSystem(toRemove: IParticleSystem): number;
  40634. /**
  40635. * Remove a animation for the list of scene's animations
  40636. * @param toRemove defines the animation to remove
  40637. * @returns the index where the animation was in the animation list
  40638. */
  40639. removeAnimation(toRemove: Animation): number;
  40640. /**
  40641. * Will stop the animation of the given target
  40642. * @param target - the target
  40643. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  40644. * @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)
  40645. */
  40646. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  40647. /**
  40648. * Removes the given animation group from this scene.
  40649. * @param toRemove The animation group to remove
  40650. * @returns The index of the removed animation group
  40651. */
  40652. removeAnimationGroup(toRemove: AnimationGroup): number;
  40653. /**
  40654. * Removes the given multi-material from this scene.
  40655. * @param toRemove The multi-material to remove
  40656. * @returns The index of the removed multi-material
  40657. */
  40658. removeMultiMaterial(toRemove: MultiMaterial): number;
  40659. /**
  40660. * Removes the given material from this scene.
  40661. * @param toRemove The material to remove
  40662. * @returns The index of the removed material
  40663. */
  40664. removeMaterial(toRemove: Material): number;
  40665. /**
  40666. * Removes the given action manager from this scene.
  40667. * @param toRemove The action manager to remove
  40668. * @returns The index of the removed action manager
  40669. */
  40670. removeActionManager(toRemove: AbstractActionManager): number;
  40671. /**
  40672. * Removes the given texture from this scene.
  40673. * @param toRemove The texture to remove
  40674. * @returns The index of the removed texture
  40675. */
  40676. removeTexture(toRemove: BaseTexture): number;
  40677. /**
  40678. * Adds the given light to this scene
  40679. * @param newLight The light to add
  40680. */
  40681. addLight(newLight: Light): void;
  40682. /**
  40683. * Sorts the list list based on light priorities
  40684. */
  40685. sortLightsByPriority(): void;
  40686. /**
  40687. * Adds the given camera to this scene
  40688. * @param newCamera The camera to add
  40689. */
  40690. addCamera(newCamera: Camera): void;
  40691. /**
  40692. * Adds the given skeleton to this scene
  40693. * @param newSkeleton The skeleton to add
  40694. */
  40695. addSkeleton(newSkeleton: Skeleton): void;
  40696. /**
  40697. * Adds the given particle system to this scene
  40698. * @param newParticleSystem The particle system to add
  40699. */
  40700. addParticleSystem(newParticleSystem: IParticleSystem): void;
  40701. /**
  40702. * Adds the given animation to this scene
  40703. * @param newAnimation The animation to add
  40704. */
  40705. addAnimation(newAnimation: Animation): void;
  40706. /**
  40707. * Adds the given animation group to this scene.
  40708. * @param newAnimationGroup The animation group to add
  40709. */
  40710. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  40711. /**
  40712. * Adds the given multi-material to this scene
  40713. * @param newMultiMaterial The multi-material to add
  40714. */
  40715. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  40716. /**
  40717. * Adds the given material to this scene
  40718. * @param newMaterial The material to add
  40719. */
  40720. addMaterial(newMaterial: Material): void;
  40721. /**
  40722. * Adds the given morph target to this scene
  40723. * @param newMorphTargetManager The morph target to add
  40724. */
  40725. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  40726. /**
  40727. * Adds the given geometry to this scene
  40728. * @param newGeometry The geometry to add
  40729. */
  40730. addGeometry(newGeometry: Geometry): void;
  40731. /**
  40732. * Adds the given action manager to this scene
  40733. * @param newActionManager The action manager to add
  40734. */
  40735. addActionManager(newActionManager: AbstractActionManager): void;
  40736. /**
  40737. * Adds the given texture to this scene.
  40738. * @param newTexture The texture to add
  40739. */
  40740. addTexture(newTexture: BaseTexture): void;
  40741. /**
  40742. * Switch active camera
  40743. * @param newCamera defines the new active camera
  40744. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  40745. */
  40746. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  40747. /**
  40748. * sets the active camera of the scene using its ID
  40749. * @param id defines the camera's ID
  40750. * @return the new active camera or null if none found.
  40751. */
  40752. setActiveCameraByID(id: string): Nullable<Camera>;
  40753. /**
  40754. * sets the active camera of the scene using its name
  40755. * @param name defines the camera's name
  40756. * @returns the new active camera or null if none found.
  40757. */
  40758. setActiveCameraByName(name: string): Nullable<Camera>;
  40759. /**
  40760. * get an animation group using its name
  40761. * @param name defines the material's name
  40762. * @return the animation group or null if none found.
  40763. */
  40764. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  40765. /**
  40766. * Get a material using its unique id
  40767. * @param uniqueId defines the material's unique id
  40768. * @return the material or null if none found.
  40769. */
  40770. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  40771. /**
  40772. * get a material using its id
  40773. * @param id defines the material's ID
  40774. * @return the material or null if none found.
  40775. */
  40776. getMaterialByID(id: string): Nullable<Material>;
  40777. /**
  40778. * Gets a the last added material using a given id
  40779. * @param id defines the material's ID
  40780. * @return the last material with the given id or null if none found.
  40781. */
  40782. getLastMaterialByID(id: string): Nullable<Material>;
  40783. /**
  40784. * Gets a material using its name
  40785. * @param name defines the material's name
  40786. * @return the material or null if none found.
  40787. */
  40788. getMaterialByName(name: string): Nullable<Material>;
  40789. /**
  40790. * Get a texture using its unique id
  40791. * @param uniqueId defines the texture's unique id
  40792. * @return the texture or null if none found.
  40793. */
  40794. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  40795. /**
  40796. * Gets a camera using its id
  40797. * @param id defines the id to look for
  40798. * @returns the camera or null if not found
  40799. */
  40800. getCameraByID(id: string): Nullable<Camera>;
  40801. /**
  40802. * Gets a camera using its unique id
  40803. * @param uniqueId defines the unique id to look for
  40804. * @returns the camera or null if not found
  40805. */
  40806. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  40807. /**
  40808. * Gets a camera using its name
  40809. * @param name defines the camera's name
  40810. * @return the camera or null if none found.
  40811. */
  40812. getCameraByName(name: string): Nullable<Camera>;
  40813. /**
  40814. * Gets a bone using its id
  40815. * @param id defines the bone's id
  40816. * @return the bone or null if not found
  40817. */
  40818. getBoneByID(id: string): Nullable<Bone>;
  40819. /**
  40820. * Gets a bone using its id
  40821. * @param name defines the bone's name
  40822. * @return the bone or null if not found
  40823. */
  40824. getBoneByName(name: string): Nullable<Bone>;
  40825. /**
  40826. * Gets a light node using its name
  40827. * @param name defines the the light's name
  40828. * @return the light or null if none found.
  40829. */
  40830. getLightByName(name: string): Nullable<Light>;
  40831. /**
  40832. * Gets a light node using its id
  40833. * @param id defines the light's id
  40834. * @return the light or null if none found.
  40835. */
  40836. getLightByID(id: string): Nullable<Light>;
  40837. /**
  40838. * Gets a light node using its scene-generated unique ID
  40839. * @param uniqueId defines the light's unique id
  40840. * @return the light or null if none found.
  40841. */
  40842. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  40843. /**
  40844. * Gets a particle system by id
  40845. * @param id defines the particle system id
  40846. * @return the corresponding system or null if none found
  40847. */
  40848. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  40849. /**
  40850. * Gets a geometry using its ID
  40851. * @param id defines the geometry's id
  40852. * @return the geometry or null if none found.
  40853. */
  40854. getGeometryByID(id: string): Nullable<Geometry>;
  40855. private _getGeometryByUniqueID;
  40856. /**
  40857. * Add a new geometry to this scene
  40858. * @param geometry defines the geometry to be added to the scene.
  40859. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  40860. * @return a boolean defining if the geometry was added or not
  40861. */
  40862. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  40863. /**
  40864. * Removes an existing geometry
  40865. * @param geometry defines the geometry to be removed from the scene
  40866. * @return a boolean defining if the geometry was removed or not
  40867. */
  40868. removeGeometry(geometry: Geometry): boolean;
  40869. /**
  40870. * Gets the list of geometries attached to the scene
  40871. * @returns an array of Geometry
  40872. */
  40873. getGeometries(): Geometry[];
  40874. /**
  40875. * Gets the first added mesh found of a given ID
  40876. * @param id defines the id to search for
  40877. * @return the mesh found or null if not found at all
  40878. */
  40879. getMeshByID(id: string): Nullable<AbstractMesh>;
  40880. /**
  40881. * Gets a list of meshes using their id
  40882. * @param id defines the id to search for
  40883. * @returns a list of meshes
  40884. */
  40885. getMeshesByID(id: string): Array<AbstractMesh>;
  40886. /**
  40887. * Gets the first added transform node found of a given ID
  40888. * @param id defines the id to search for
  40889. * @return the found transform node or null if not found at all.
  40890. */
  40891. getTransformNodeByID(id: string): Nullable<TransformNode>;
  40892. /**
  40893. * Gets a transform node with its auto-generated unique id
  40894. * @param uniqueId efines the unique id to search for
  40895. * @return the found transform node or null if not found at all.
  40896. */
  40897. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  40898. /**
  40899. * Gets a list of transform nodes using their id
  40900. * @param id defines the id to search for
  40901. * @returns a list of transform nodes
  40902. */
  40903. getTransformNodesByID(id: string): Array<TransformNode>;
  40904. /**
  40905. * Gets a mesh with its auto-generated unique id
  40906. * @param uniqueId defines the unique id to search for
  40907. * @return the found mesh or null if not found at all.
  40908. */
  40909. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  40910. /**
  40911. * Gets a the last added mesh using a given id
  40912. * @param id defines the id to search for
  40913. * @return the found mesh or null if not found at all.
  40914. */
  40915. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  40916. /**
  40917. * Gets a the last added node (Mesh, Camera, Light) using a given id
  40918. * @param id defines the id to search for
  40919. * @return the found node or null if not found at all
  40920. */
  40921. getLastEntryByID(id: string): Nullable<Node>;
  40922. /**
  40923. * Gets a node (Mesh, Camera, Light) using a given id
  40924. * @param id defines the id to search for
  40925. * @return the found node or null if not found at all
  40926. */
  40927. getNodeByID(id: string): Nullable<Node>;
  40928. /**
  40929. * Gets a node (Mesh, Camera, Light) using a given name
  40930. * @param name defines the name to search for
  40931. * @return the found node or null if not found at all.
  40932. */
  40933. getNodeByName(name: string): Nullable<Node>;
  40934. /**
  40935. * Gets a mesh using a given name
  40936. * @param name defines the name to search for
  40937. * @return the found mesh or null if not found at all.
  40938. */
  40939. getMeshByName(name: string): Nullable<AbstractMesh>;
  40940. /**
  40941. * Gets a transform node using a given name
  40942. * @param name defines the name to search for
  40943. * @return the found transform node or null if not found at all.
  40944. */
  40945. getTransformNodeByName(name: string): Nullable<TransformNode>;
  40946. /**
  40947. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  40948. * @param id defines the id to search for
  40949. * @return the found skeleton or null if not found at all.
  40950. */
  40951. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  40952. /**
  40953. * Gets a skeleton using a given auto generated unique id
  40954. * @param uniqueId defines the unique id to search for
  40955. * @return the found skeleton or null if not found at all.
  40956. */
  40957. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  40958. /**
  40959. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  40960. * @param id defines the id to search for
  40961. * @return the found skeleton or null if not found at all.
  40962. */
  40963. getSkeletonById(id: string): Nullable<Skeleton>;
  40964. /**
  40965. * Gets a skeleton using a given name
  40966. * @param name defines the name to search for
  40967. * @return the found skeleton or null if not found at all.
  40968. */
  40969. getSkeletonByName(name: string): Nullable<Skeleton>;
  40970. /**
  40971. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  40972. * @param id defines the id to search for
  40973. * @return the found morph target manager or null if not found at all.
  40974. */
  40975. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  40976. /**
  40977. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  40978. * @param id defines the id to search for
  40979. * @return the found morph target or null if not found at all.
  40980. */
  40981. getMorphTargetById(id: string): Nullable<MorphTarget>;
  40982. /**
  40983. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  40984. * @param name defines the name to search for
  40985. * @return the found morph target or null if not found at all.
  40986. */
  40987. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  40988. /**
  40989. * Gets a post process using a given name (if many are found, this function will pick the first one)
  40990. * @param name defines the name to search for
  40991. * @return the found post process or null if not found at all.
  40992. */
  40993. getPostProcessByName(name: string): Nullable<PostProcess>;
  40994. /**
  40995. * Gets a boolean indicating if the given mesh is active
  40996. * @param mesh defines the mesh to look for
  40997. * @returns true if the mesh is in the active list
  40998. */
  40999. isActiveMesh(mesh: AbstractMesh): boolean;
  41000. /**
  41001. * Return a unique id as a string which can serve as an identifier for the scene
  41002. */
  41003. get uid(): string;
  41004. /**
  41005. * Add an externaly attached data from its key.
  41006. * This method call will fail and return false, if such key already exists.
  41007. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  41008. * @param key the unique key that identifies the data
  41009. * @param data the data object to associate to the key for this Engine instance
  41010. * @return true if no such key were already present and the data was added successfully, false otherwise
  41011. */
  41012. addExternalData<T>(key: string, data: T): boolean;
  41013. /**
  41014. * Get an externaly attached data from its key
  41015. * @param key the unique key that identifies the data
  41016. * @return the associated data, if present (can be null), or undefined if not present
  41017. */
  41018. getExternalData<T>(key: string): Nullable<T>;
  41019. /**
  41020. * Get an externaly attached data from its key, create it using a factory if it's not already present
  41021. * @param key the unique key that identifies the data
  41022. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  41023. * @return the associated data, can be null if the factory returned null.
  41024. */
  41025. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  41026. /**
  41027. * Remove an externaly attached data from the Engine instance
  41028. * @param key the unique key that identifies the data
  41029. * @return true if the data was successfully removed, false if it doesn't exist
  41030. */
  41031. removeExternalData(key: string): boolean;
  41032. private _evaluateSubMesh;
  41033. /**
  41034. * Clear the processed materials smart array preventing retention point in material dispose.
  41035. */
  41036. freeProcessedMaterials(): void;
  41037. private _preventFreeActiveMeshesAndRenderingGroups;
  41038. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  41039. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  41040. * when disposing several meshes in a row or a hierarchy of meshes.
  41041. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  41042. */
  41043. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  41044. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  41045. /**
  41046. * Clear the active meshes smart array preventing retention point in mesh dispose.
  41047. */
  41048. freeActiveMeshes(): void;
  41049. /**
  41050. * Clear the info related to rendering groups preventing retention points during dispose.
  41051. */
  41052. freeRenderingGroups(): void;
  41053. /** @hidden */
  41054. _isInIntermediateRendering(): boolean;
  41055. /**
  41056. * Lambda returning the list of potentially active meshes.
  41057. */
  41058. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  41059. /**
  41060. * Lambda returning the list of potentially active sub meshes.
  41061. */
  41062. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  41063. /**
  41064. * Lambda returning the list of potentially intersecting sub meshes.
  41065. */
  41066. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  41067. /**
  41068. * Lambda returning the list of potentially colliding sub meshes.
  41069. */
  41070. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  41071. private _activeMeshesFrozen;
  41072. private _skipEvaluateActiveMeshesCompletely;
  41073. /**
  41074. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  41075. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  41076. * @returns the current scene
  41077. */
  41078. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  41079. /**
  41080. * Use this function to restart evaluating active meshes on every frame
  41081. * @returns the current scene
  41082. */
  41083. unfreezeActiveMeshes(): Scene;
  41084. private _evaluateActiveMeshes;
  41085. private _activeMesh;
  41086. /**
  41087. * Update the transform matrix to update from the current active camera
  41088. * @param force defines a boolean used to force the update even if cache is up to date
  41089. */
  41090. updateTransformMatrix(force?: boolean): void;
  41091. private _bindFrameBuffer;
  41092. /** @hidden */
  41093. _allowPostProcessClearColor: boolean;
  41094. /** @hidden */
  41095. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  41096. private _processSubCameras;
  41097. private _checkIntersections;
  41098. /** @hidden */
  41099. _advancePhysicsEngineStep(step: number): void;
  41100. /**
  41101. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  41102. */
  41103. getDeterministicFrameTime: () => number;
  41104. /** @hidden */
  41105. _animate(): void;
  41106. /** Execute all animations (for a frame) */
  41107. animate(): void;
  41108. /**
  41109. * Render the scene
  41110. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  41111. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  41112. */
  41113. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  41114. /**
  41115. * Freeze all materials
  41116. * A frozen material will not be updatable but should be faster to render
  41117. */
  41118. freezeMaterials(): void;
  41119. /**
  41120. * Unfreeze all materials
  41121. * A frozen material will not be updatable but should be faster to render
  41122. */
  41123. unfreezeMaterials(): void;
  41124. /**
  41125. * Releases all held ressources
  41126. */
  41127. dispose(): void;
  41128. /**
  41129. * Gets if the scene is already disposed
  41130. */
  41131. get isDisposed(): boolean;
  41132. /**
  41133. * Call this function to reduce memory footprint of the scene.
  41134. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  41135. */
  41136. clearCachedVertexData(): void;
  41137. /**
  41138. * This function will remove the local cached buffer data from texture.
  41139. * It will save memory but will prevent the texture from being rebuilt
  41140. */
  41141. cleanCachedTextureBuffer(): void;
  41142. /**
  41143. * Get the world extend vectors with an optional filter
  41144. *
  41145. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  41146. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  41147. */
  41148. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  41149. min: Vector3;
  41150. max: Vector3;
  41151. };
  41152. /**
  41153. * Creates a ray that can be used to pick in the scene
  41154. * @param x defines the x coordinate of the origin (on-screen)
  41155. * @param y defines the y coordinate of the origin (on-screen)
  41156. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41157. * @param camera defines the camera to use for the picking
  41158. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41159. * @returns a Ray
  41160. */
  41161. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  41162. /**
  41163. * Creates a ray that can be used to pick in the scene
  41164. * @param x defines the x coordinate of the origin (on-screen)
  41165. * @param y defines the y coordinate of the origin (on-screen)
  41166. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41167. * @param result defines the ray where to store the picking ray
  41168. * @param camera defines the camera to use for the picking
  41169. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41170. * @returns the current scene
  41171. */
  41172. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  41173. /**
  41174. * Creates a ray that can be used to pick in the scene
  41175. * @param x defines the x coordinate of the origin (on-screen)
  41176. * @param y defines the y coordinate of the origin (on-screen)
  41177. * @param camera defines the camera to use for the picking
  41178. * @returns a Ray
  41179. */
  41180. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  41181. /**
  41182. * Creates a ray that can be used to pick in the scene
  41183. * @param x defines the x coordinate of the origin (on-screen)
  41184. * @param y defines the y coordinate of the origin (on-screen)
  41185. * @param result defines the ray where to store the picking ray
  41186. * @param camera defines the camera to use for the picking
  41187. * @returns the current scene
  41188. */
  41189. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  41190. /** Launch a ray to try to pick a mesh in the scene
  41191. * @param x position on screen
  41192. * @param y position on screen
  41193. * @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
  41194. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41195. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41196. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41197. * @returns a PickingInfo
  41198. */
  41199. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41200. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  41201. * @param x position on screen
  41202. * @param y position on screen
  41203. * @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
  41204. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41205. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41206. * @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)
  41207. */
  41208. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  41209. /** Use the given ray to pick a mesh in the scene
  41210. * @param ray The ray to use to pick meshes
  41211. * @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
  41212. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41213. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41214. * @returns a PickingInfo
  41215. */
  41216. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41217. /**
  41218. * Launch a ray to try to pick a mesh in the scene
  41219. * @param x X position on screen
  41220. * @param y Y position on screen
  41221. * @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
  41222. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41223. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41224. * @returns an array of PickingInfo
  41225. */
  41226. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41227. /**
  41228. * Launch a ray to try to pick a mesh in the scene
  41229. * @param ray Ray to use
  41230. * @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
  41231. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41232. * @returns an array of PickingInfo
  41233. */
  41234. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41235. /**
  41236. * Force the value of meshUnderPointer
  41237. * @param mesh defines the mesh to use
  41238. * @param pointerId optional pointer id when using more than one pointer
  41239. */
  41240. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  41241. /**
  41242. * Gets the mesh under the pointer
  41243. * @returns a Mesh or null if no mesh is under the pointer
  41244. */
  41245. getPointerOverMesh(): Nullable<AbstractMesh>;
  41246. /** @hidden */
  41247. _rebuildGeometries(): void;
  41248. /** @hidden */
  41249. _rebuildTextures(): void;
  41250. private _getByTags;
  41251. /**
  41252. * Get a list of meshes by tags
  41253. * @param tagsQuery defines the tags query to use
  41254. * @param forEach defines a predicate used to filter results
  41255. * @returns an array of Mesh
  41256. */
  41257. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  41258. /**
  41259. * Get a list of cameras by tags
  41260. * @param tagsQuery defines the tags query to use
  41261. * @param forEach defines a predicate used to filter results
  41262. * @returns an array of Camera
  41263. */
  41264. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  41265. /**
  41266. * Get a list of lights by tags
  41267. * @param tagsQuery defines the tags query to use
  41268. * @param forEach defines a predicate used to filter results
  41269. * @returns an array of Light
  41270. */
  41271. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  41272. /**
  41273. * Get a list of materials by tags
  41274. * @param tagsQuery defines the tags query to use
  41275. * @param forEach defines a predicate used to filter results
  41276. * @returns an array of Material
  41277. */
  41278. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  41279. /**
  41280. * Get a list of transform nodes by tags
  41281. * @param tagsQuery defines the tags query to use
  41282. * @param forEach defines a predicate used to filter results
  41283. * @returns an array of TransformNode
  41284. */
  41285. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  41286. /**
  41287. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  41288. * This allowed control for front to back rendering or reversly depending of the special needs.
  41289. *
  41290. * @param renderingGroupId The rendering group id corresponding to its index
  41291. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  41292. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  41293. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  41294. */
  41295. 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;
  41296. /**
  41297. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  41298. *
  41299. * @param renderingGroupId The rendering group id corresponding to its index
  41300. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  41301. * @param depth Automatically clears depth between groups if true and autoClear is true.
  41302. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  41303. */
  41304. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  41305. /**
  41306. * Gets the current auto clear configuration for one rendering group of the rendering
  41307. * manager.
  41308. * @param index the rendering group index to get the information for
  41309. * @returns The auto clear setup for the requested rendering group
  41310. */
  41311. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  41312. private _blockMaterialDirtyMechanism;
  41313. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  41314. get blockMaterialDirtyMechanism(): boolean;
  41315. set blockMaterialDirtyMechanism(value: boolean);
  41316. /**
  41317. * Will flag all materials as dirty to trigger new shader compilation
  41318. * @param flag defines the flag used to specify which material part must be marked as dirty
  41319. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  41320. */
  41321. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41322. /** @hidden */
  41323. _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;
  41324. /** @hidden */
  41325. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41326. /** @hidden */
  41327. _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;
  41328. /** @hidden */
  41329. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  41330. /** @hidden */
  41331. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41332. /** @hidden */
  41333. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41334. }
  41335. }
  41336. declare module BABYLON {
  41337. /**
  41338. * Set of assets to keep when moving a scene into an asset container.
  41339. */
  41340. export class KeepAssets extends AbstractScene {
  41341. }
  41342. /**
  41343. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  41344. */
  41345. export class InstantiatedEntries {
  41346. /**
  41347. * List of new root nodes (eg. nodes with no parent)
  41348. */
  41349. rootNodes: TransformNode[];
  41350. /**
  41351. * List of new skeletons
  41352. */
  41353. skeletons: Skeleton[];
  41354. /**
  41355. * List of new animation groups
  41356. */
  41357. animationGroups: AnimationGroup[];
  41358. }
  41359. /**
  41360. * Container with a set of assets that can be added or removed from a scene.
  41361. */
  41362. export class AssetContainer extends AbstractScene {
  41363. private _wasAddedToScene;
  41364. /**
  41365. * The scene the AssetContainer belongs to.
  41366. */
  41367. scene: Scene;
  41368. /**
  41369. * Instantiates an AssetContainer.
  41370. * @param scene The scene the AssetContainer belongs to.
  41371. */
  41372. constructor(scene: Scene);
  41373. /**
  41374. * Instantiate or clone all meshes and add the new ones to the scene.
  41375. * Skeletons and animation groups will all be cloned
  41376. * @param nameFunction defines an optional function used to get new names for clones
  41377. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  41378. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  41379. */
  41380. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  41381. /**
  41382. * Adds all the assets from the container to the scene.
  41383. */
  41384. addAllToScene(): void;
  41385. /**
  41386. * Removes all the assets in the container from the scene
  41387. */
  41388. removeAllFromScene(): void;
  41389. /**
  41390. * Disposes all the assets in the container
  41391. */
  41392. dispose(): void;
  41393. private _moveAssets;
  41394. /**
  41395. * Removes all the assets contained in the scene and adds them to the container.
  41396. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  41397. */
  41398. moveAllFromScene(keepAssets?: KeepAssets): void;
  41399. /**
  41400. * 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.
  41401. * @returns the root mesh
  41402. */
  41403. createRootMesh(): Mesh;
  41404. /**
  41405. * Merge animations (direct and animation groups) from this asset container into a scene
  41406. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41407. * @param animatables set of animatables to retarget to a node from the scene
  41408. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  41409. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  41410. */
  41411. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  41412. }
  41413. }
  41414. declare module BABYLON {
  41415. /**
  41416. * Defines how the parser contract is defined.
  41417. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  41418. */
  41419. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  41420. /**
  41421. * Defines how the individual parser contract is defined.
  41422. * These parser can parse an individual asset
  41423. */
  41424. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  41425. /**
  41426. * Base class of the scene acting as a container for the different elements composing a scene.
  41427. * This class is dynamically extended by the different components of the scene increasing
  41428. * flexibility and reducing coupling
  41429. */
  41430. export abstract class AbstractScene {
  41431. /**
  41432. * Stores the list of available parsers in the application.
  41433. */
  41434. private static _BabylonFileParsers;
  41435. /**
  41436. * Stores the list of available individual parsers in the application.
  41437. */
  41438. private static _IndividualBabylonFileParsers;
  41439. /**
  41440. * Adds a parser in the list of available ones
  41441. * @param name Defines the name of the parser
  41442. * @param parser Defines the parser to add
  41443. */
  41444. static AddParser(name: string, parser: BabylonFileParser): void;
  41445. /**
  41446. * Gets a general parser from the list of avaialble ones
  41447. * @param name Defines the name of the parser
  41448. * @returns the requested parser or null
  41449. */
  41450. static GetParser(name: string): Nullable<BabylonFileParser>;
  41451. /**
  41452. * Adds n individual parser in the list of available ones
  41453. * @param name Defines the name of the parser
  41454. * @param parser Defines the parser to add
  41455. */
  41456. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  41457. /**
  41458. * Gets an individual parser from the list of avaialble ones
  41459. * @param name Defines the name of the parser
  41460. * @returns the requested parser or null
  41461. */
  41462. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  41463. /**
  41464. * Parser json data and populate both a scene and its associated container object
  41465. * @param jsonData Defines the data to parse
  41466. * @param scene Defines the scene to parse the data for
  41467. * @param container Defines the container attached to the parsing sequence
  41468. * @param rootUrl Defines the root url of the data
  41469. */
  41470. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  41471. /**
  41472. * Gets the list of root nodes (ie. nodes with no parent)
  41473. */
  41474. rootNodes: Node[];
  41475. /** All of the cameras added to this scene
  41476. * @see https://doc.babylonjs.com/babylon101/cameras
  41477. */
  41478. cameras: Camera[];
  41479. /**
  41480. * All of the lights added to this scene
  41481. * @see https://doc.babylonjs.com/babylon101/lights
  41482. */
  41483. lights: Light[];
  41484. /**
  41485. * All of the (abstract) meshes added to this scene
  41486. */
  41487. meshes: AbstractMesh[];
  41488. /**
  41489. * The list of skeletons added to the scene
  41490. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  41491. */
  41492. skeletons: Skeleton[];
  41493. /**
  41494. * All of the particle systems added to this scene
  41495. * @see https://doc.babylonjs.com/babylon101/particles
  41496. */
  41497. particleSystems: IParticleSystem[];
  41498. /**
  41499. * Gets a list of Animations associated with the scene
  41500. */
  41501. animations: Animation[];
  41502. /**
  41503. * All of the animation groups added to this scene
  41504. * @see https://doc.babylonjs.com/how_to/group
  41505. */
  41506. animationGroups: AnimationGroup[];
  41507. /**
  41508. * All of the multi-materials added to this scene
  41509. * @see https://doc.babylonjs.com/how_to/multi_materials
  41510. */
  41511. multiMaterials: MultiMaterial[];
  41512. /**
  41513. * All of the materials added to this scene
  41514. * In the context of a Scene, it is not supposed to be modified manually.
  41515. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  41516. * Note also that the order of the Material within the array is not significant and might change.
  41517. * @see https://doc.babylonjs.com/babylon101/materials
  41518. */
  41519. materials: Material[];
  41520. /**
  41521. * The list of morph target managers added to the scene
  41522. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  41523. */
  41524. morphTargetManagers: MorphTargetManager[];
  41525. /**
  41526. * The list of geometries used in the scene.
  41527. */
  41528. geometries: Geometry[];
  41529. /**
  41530. * All of the tranform nodes added to this scene
  41531. * In the context of a Scene, it is not supposed to be modified manually.
  41532. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  41533. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  41534. * @see https://doc.babylonjs.com/how_to/transformnode
  41535. */
  41536. transformNodes: TransformNode[];
  41537. /**
  41538. * ActionManagers available on the scene.
  41539. */
  41540. actionManagers: AbstractActionManager[];
  41541. /**
  41542. * Textures to keep.
  41543. */
  41544. textures: BaseTexture[];
  41545. /** @hidden */
  41546. protected _environmentTexture: Nullable<BaseTexture>;
  41547. /**
  41548. * Texture used in all pbr material as the reflection texture.
  41549. * As in the majority of the scene they are the same (exception for multi room and so on),
  41550. * this is easier to reference from here than from all the materials.
  41551. */
  41552. get environmentTexture(): Nullable<BaseTexture>;
  41553. set environmentTexture(value: Nullable<BaseTexture>);
  41554. /**
  41555. * The list of postprocesses added to the scene
  41556. */
  41557. postProcesses: PostProcess[];
  41558. /**
  41559. * @returns all meshes, lights, cameras, transformNodes and bones
  41560. */
  41561. getNodes(): Array<Node>;
  41562. }
  41563. }
  41564. declare module BABYLON {
  41565. /**
  41566. * Interface used to define options for Sound class
  41567. */
  41568. export interface ISoundOptions {
  41569. /**
  41570. * Does the sound autoplay once loaded.
  41571. */
  41572. autoplay?: boolean;
  41573. /**
  41574. * Does the sound loop after it finishes playing once.
  41575. */
  41576. loop?: boolean;
  41577. /**
  41578. * Sound's volume
  41579. */
  41580. volume?: number;
  41581. /**
  41582. * Is it a spatial sound?
  41583. */
  41584. spatialSound?: boolean;
  41585. /**
  41586. * Maximum distance to hear that sound
  41587. */
  41588. maxDistance?: number;
  41589. /**
  41590. * Uses user defined attenuation function
  41591. */
  41592. useCustomAttenuation?: boolean;
  41593. /**
  41594. * Define the roll off factor of spatial sounds.
  41595. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41596. */
  41597. rolloffFactor?: number;
  41598. /**
  41599. * Define the reference distance the sound should be heard perfectly.
  41600. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41601. */
  41602. refDistance?: number;
  41603. /**
  41604. * Define the distance attenuation model the sound will follow.
  41605. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41606. */
  41607. distanceModel?: string;
  41608. /**
  41609. * Defines the playback speed (1 by default)
  41610. */
  41611. playbackRate?: number;
  41612. /**
  41613. * Defines if the sound is from a streaming source
  41614. */
  41615. streaming?: boolean;
  41616. /**
  41617. * Defines an optional length (in seconds) inside the sound file
  41618. */
  41619. length?: number;
  41620. /**
  41621. * Defines an optional offset (in seconds) inside the sound file
  41622. */
  41623. offset?: number;
  41624. /**
  41625. * If true, URLs will not be required to state the audio file codec to use.
  41626. */
  41627. skipCodecCheck?: boolean;
  41628. }
  41629. /**
  41630. * Defines a sound that can be played in the application.
  41631. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  41632. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41633. */
  41634. export class Sound {
  41635. /**
  41636. * The name of the sound in the scene.
  41637. */
  41638. name: string;
  41639. /**
  41640. * Does the sound autoplay once loaded.
  41641. */
  41642. autoplay: boolean;
  41643. /**
  41644. * Does the sound loop after it finishes playing once.
  41645. */
  41646. loop: boolean;
  41647. /**
  41648. * Does the sound use a custom attenuation curve to simulate the falloff
  41649. * happening when the source gets further away from the camera.
  41650. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41651. */
  41652. useCustomAttenuation: boolean;
  41653. /**
  41654. * The sound track id this sound belongs to.
  41655. */
  41656. soundTrackId: number;
  41657. /**
  41658. * Is this sound currently played.
  41659. */
  41660. isPlaying: boolean;
  41661. /**
  41662. * Is this sound currently paused.
  41663. */
  41664. isPaused: boolean;
  41665. /**
  41666. * Does this sound enables spatial sound.
  41667. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41668. */
  41669. spatialSound: boolean;
  41670. /**
  41671. * Define the reference distance the sound should be heard perfectly.
  41672. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41673. */
  41674. refDistance: number;
  41675. /**
  41676. * Define the roll off factor of spatial sounds.
  41677. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41678. */
  41679. rolloffFactor: number;
  41680. /**
  41681. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  41682. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41683. */
  41684. maxDistance: number;
  41685. /**
  41686. * Define the distance attenuation model the sound will follow.
  41687. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41688. */
  41689. distanceModel: string;
  41690. /**
  41691. * @hidden
  41692. * Back Compat
  41693. **/
  41694. onended: () => any;
  41695. /**
  41696. * Gets or sets an object used to store user defined information for the sound.
  41697. */
  41698. metadata: any;
  41699. /**
  41700. * Observable event when the current playing sound finishes.
  41701. */
  41702. onEndedObservable: Observable<Sound>;
  41703. private _panningModel;
  41704. private _playbackRate;
  41705. private _streaming;
  41706. private _startTime;
  41707. private _startOffset;
  41708. private _position;
  41709. /** @hidden */
  41710. _positionInEmitterSpace: boolean;
  41711. private _localDirection;
  41712. private _volume;
  41713. private _isReadyToPlay;
  41714. private _isDirectional;
  41715. private _readyToPlayCallback;
  41716. private _audioBuffer;
  41717. private _soundSource;
  41718. private _streamingSource;
  41719. private _soundPanner;
  41720. private _soundGain;
  41721. private _inputAudioNode;
  41722. private _outputAudioNode;
  41723. private _coneInnerAngle;
  41724. private _coneOuterAngle;
  41725. private _coneOuterGain;
  41726. private _scene;
  41727. private _connectedTransformNode;
  41728. private _customAttenuationFunction;
  41729. private _registerFunc;
  41730. private _isOutputConnected;
  41731. private _htmlAudioElement;
  41732. private _urlType;
  41733. private _length?;
  41734. private _offset?;
  41735. /** @hidden */
  41736. static _SceneComponentInitialization: (scene: Scene) => void;
  41737. /**
  41738. * Create a sound and attach it to a scene
  41739. * @param name Name of your sound
  41740. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  41741. * @param scene defines the scene the sound belongs to
  41742. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  41743. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  41744. */
  41745. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  41746. /**
  41747. * Release the sound and its associated resources
  41748. */
  41749. dispose(): void;
  41750. /**
  41751. * Gets if the sounds is ready to be played or not.
  41752. * @returns true if ready, otherwise false
  41753. */
  41754. isReady(): boolean;
  41755. private _soundLoaded;
  41756. /**
  41757. * Sets the data of the sound from an audiobuffer
  41758. * @param audioBuffer The audioBuffer containing the data
  41759. */
  41760. setAudioBuffer(audioBuffer: AudioBuffer): void;
  41761. /**
  41762. * Updates the current sounds options such as maxdistance, loop...
  41763. * @param options A JSON object containing values named as the object properties
  41764. */
  41765. updateOptions(options: ISoundOptions): void;
  41766. private _createSpatialParameters;
  41767. private _updateSpatialParameters;
  41768. /**
  41769. * Switch the panning model to HRTF:
  41770. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41771. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41772. */
  41773. switchPanningModelToHRTF(): void;
  41774. /**
  41775. * Switch the panning model to Equal Power:
  41776. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41777. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41778. */
  41779. switchPanningModelToEqualPower(): void;
  41780. private _switchPanningModel;
  41781. /**
  41782. * Connect this sound to a sound track audio node like gain...
  41783. * @param soundTrackAudioNode the sound track audio node to connect to
  41784. */
  41785. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  41786. /**
  41787. * Transform this sound into a directional source
  41788. * @param coneInnerAngle Size of the inner cone in degree
  41789. * @param coneOuterAngle Size of the outer cone in degree
  41790. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  41791. */
  41792. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  41793. /**
  41794. * Gets or sets the inner angle for the directional cone.
  41795. */
  41796. get directionalConeInnerAngle(): number;
  41797. /**
  41798. * Gets or sets the inner angle for the directional cone.
  41799. */
  41800. set directionalConeInnerAngle(value: number);
  41801. /**
  41802. * Gets or sets the outer angle for the directional cone.
  41803. */
  41804. get directionalConeOuterAngle(): number;
  41805. /**
  41806. * Gets or sets the outer angle for the directional cone.
  41807. */
  41808. set directionalConeOuterAngle(value: number);
  41809. /**
  41810. * Sets the position of the emitter if spatial sound is enabled
  41811. * @param newPosition Defines the new posisiton
  41812. */
  41813. setPosition(newPosition: Vector3): void;
  41814. /**
  41815. * Sets the local direction of the emitter if spatial sound is enabled
  41816. * @param newLocalDirection Defines the new local direction
  41817. */
  41818. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  41819. private _updateDirection;
  41820. /** @hidden */
  41821. updateDistanceFromListener(): void;
  41822. /**
  41823. * Sets a new custom attenuation function for the sound.
  41824. * @param callback Defines the function used for the attenuation
  41825. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41826. */
  41827. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  41828. /**
  41829. * Play the sound
  41830. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  41831. * @param offset (optional) Start the sound at a specific time in seconds
  41832. * @param length (optional) Sound duration (in seconds)
  41833. */
  41834. play(time?: number, offset?: number, length?: number): void;
  41835. private _onended;
  41836. /**
  41837. * Stop the sound
  41838. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  41839. */
  41840. stop(time?: number): void;
  41841. /**
  41842. * Put the sound in pause
  41843. */
  41844. pause(): void;
  41845. /**
  41846. * Sets a dedicated volume for this sounds
  41847. * @param newVolume Define the new volume of the sound
  41848. * @param time Define time for gradual change to new volume
  41849. */
  41850. setVolume(newVolume: number, time?: number): void;
  41851. /**
  41852. * Set the sound play back rate
  41853. * @param newPlaybackRate Define the playback rate the sound should be played at
  41854. */
  41855. setPlaybackRate(newPlaybackRate: number): void;
  41856. /**
  41857. * Gets the volume of the sound.
  41858. * @returns the volume of the sound
  41859. */
  41860. getVolume(): number;
  41861. /**
  41862. * Attach the sound to a dedicated mesh
  41863. * @param transformNode The transform node to connect the sound with
  41864. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41865. */
  41866. attachToMesh(transformNode: TransformNode): void;
  41867. /**
  41868. * Detach the sound from the previously attached mesh
  41869. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41870. */
  41871. detachFromMesh(): void;
  41872. private _onRegisterAfterWorldMatrixUpdate;
  41873. /**
  41874. * Clone the current sound in the scene.
  41875. * @returns the new sound clone
  41876. */
  41877. clone(): Nullable<Sound>;
  41878. /**
  41879. * Gets the current underlying audio buffer containing the data
  41880. * @returns the audio buffer
  41881. */
  41882. getAudioBuffer(): Nullable<AudioBuffer>;
  41883. /**
  41884. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  41885. * @returns the source node
  41886. */
  41887. getSoundSource(): Nullable<AudioBufferSourceNode>;
  41888. /**
  41889. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  41890. * @returns the gain node
  41891. */
  41892. getSoundGain(): Nullable<GainNode>;
  41893. /**
  41894. * Serializes the Sound in a JSON representation
  41895. * @returns the JSON representation of the sound
  41896. */
  41897. serialize(): any;
  41898. /**
  41899. * Parse a JSON representation of a sound to innstantiate in a given scene
  41900. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  41901. * @param scene Define the scene the new parsed sound should be created in
  41902. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  41903. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  41904. * @returns the newly parsed sound
  41905. */
  41906. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  41907. }
  41908. }
  41909. declare module BABYLON {
  41910. /**
  41911. * This defines an action helpful to play a defined sound on a triggered action.
  41912. */
  41913. export class PlaySoundAction extends Action {
  41914. private _sound;
  41915. /**
  41916. * Instantiate the action
  41917. * @param triggerOptions defines the trigger options
  41918. * @param sound defines the sound to play
  41919. * @param condition defines the trigger related conditions
  41920. */
  41921. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41922. /** @hidden */
  41923. _prepare(): void;
  41924. /**
  41925. * Execute the action and play the sound.
  41926. */
  41927. execute(): void;
  41928. /**
  41929. * Serializes the actions and its related information.
  41930. * @param parent defines the object to serialize in
  41931. * @returns the serialized object
  41932. */
  41933. serialize(parent: any): any;
  41934. }
  41935. /**
  41936. * This defines an action helpful to stop a defined sound on a triggered action.
  41937. */
  41938. export class StopSoundAction extends Action {
  41939. private _sound;
  41940. /**
  41941. * Instantiate the action
  41942. * @param triggerOptions defines the trigger options
  41943. * @param sound defines the sound to stop
  41944. * @param condition defines the trigger related conditions
  41945. */
  41946. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41947. /** @hidden */
  41948. _prepare(): void;
  41949. /**
  41950. * Execute the action and stop the sound.
  41951. */
  41952. execute(): void;
  41953. /**
  41954. * Serializes the actions and its related information.
  41955. * @param parent defines the object to serialize in
  41956. * @returns the serialized object
  41957. */
  41958. serialize(parent: any): any;
  41959. }
  41960. }
  41961. declare module BABYLON {
  41962. /**
  41963. * This defines an action responsible to change the value of a property
  41964. * by interpolating between its current value and the newly set one once triggered.
  41965. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  41966. */
  41967. export class InterpolateValueAction extends Action {
  41968. /**
  41969. * Defines the path of the property where the value should be interpolated
  41970. */
  41971. propertyPath: string;
  41972. /**
  41973. * Defines the target value at the end of the interpolation.
  41974. */
  41975. value: any;
  41976. /**
  41977. * Defines the time it will take for the property to interpolate to the value.
  41978. */
  41979. duration: number;
  41980. /**
  41981. * Defines if the other scene animations should be stopped when the action has been triggered
  41982. */
  41983. stopOtherAnimations?: boolean;
  41984. /**
  41985. * Defines a callback raised once the interpolation animation has been done.
  41986. */
  41987. onInterpolationDone?: () => void;
  41988. /**
  41989. * Observable triggered once the interpolation animation has been done.
  41990. */
  41991. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  41992. private _target;
  41993. private _effectiveTarget;
  41994. private _property;
  41995. /**
  41996. * Instantiate the action
  41997. * @param triggerOptions defines the trigger options
  41998. * @param target defines the object containing the value to interpolate
  41999. * @param propertyPath defines the path to the property in the target object
  42000. * @param value defines the target value at the end of the interpolation
  42001. * @param duration deines the time it will take for the property to interpolate to the value.
  42002. * @param condition defines the trigger related conditions
  42003. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  42004. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  42005. */
  42006. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  42007. /** @hidden */
  42008. _prepare(): void;
  42009. /**
  42010. * Execute the action starts the value interpolation.
  42011. */
  42012. execute(): void;
  42013. /**
  42014. * Serializes the actions and its related information.
  42015. * @param parent defines the object to serialize in
  42016. * @returns the serialized object
  42017. */
  42018. serialize(parent: any): any;
  42019. }
  42020. }
  42021. declare module BABYLON {
  42022. /**
  42023. * Options allowed during the creation of a sound track.
  42024. */
  42025. export interface ISoundTrackOptions {
  42026. /**
  42027. * The volume the sound track should take during creation
  42028. */
  42029. volume?: number;
  42030. /**
  42031. * Define if the sound track is the main sound track of the scene
  42032. */
  42033. mainTrack?: boolean;
  42034. }
  42035. /**
  42036. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  42037. * It will be also used in a future release to apply effects on a specific track.
  42038. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42039. */
  42040. export class SoundTrack {
  42041. /**
  42042. * The unique identifier of the sound track in the scene.
  42043. */
  42044. id: number;
  42045. /**
  42046. * The list of sounds included in the sound track.
  42047. */
  42048. soundCollection: Array<Sound>;
  42049. private _outputAudioNode;
  42050. private _scene;
  42051. private _connectedAnalyser;
  42052. private _options;
  42053. private _isInitialized;
  42054. /**
  42055. * Creates a new sound track.
  42056. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42057. * @param scene Define the scene the sound track belongs to
  42058. * @param options
  42059. */
  42060. constructor(scene: Scene, options?: ISoundTrackOptions);
  42061. private _initializeSoundTrackAudioGraph;
  42062. /**
  42063. * Release the sound track and its associated resources
  42064. */
  42065. dispose(): void;
  42066. /**
  42067. * Adds a sound to this sound track
  42068. * @param sound define the cound to add
  42069. * @ignoreNaming
  42070. */
  42071. AddSound(sound: Sound): void;
  42072. /**
  42073. * Removes a sound to this sound track
  42074. * @param sound define the cound to remove
  42075. * @ignoreNaming
  42076. */
  42077. RemoveSound(sound: Sound): void;
  42078. /**
  42079. * Set a global volume for the full sound track.
  42080. * @param newVolume Define the new volume of the sound track
  42081. */
  42082. setVolume(newVolume: number): void;
  42083. /**
  42084. * Switch the panning model to HRTF:
  42085. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  42086. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42087. */
  42088. switchPanningModelToHRTF(): void;
  42089. /**
  42090. * Switch the panning model to Equal Power:
  42091. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  42092. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42093. */
  42094. switchPanningModelToEqualPower(): void;
  42095. /**
  42096. * Connect the sound track to an audio analyser allowing some amazing
  42097. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  42098. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  42099. * @param analyser The analyser to connect to the engine
  42100. */
  42101. connectToAnalyser(analyser: Analyser): void;
  42102. }
  42103. }
  42104. declare module BABYLON {
  42105. interface AbstractScene {
  42106. /**
  42107. * The list of sounds used in the scene.
  42108. */
  42109. sounds: Nullable<Array<Sound>>;
  42110. }
  42111. interface Scene {
  42112. /**
  42113. * @hidden
  42114. * Backing field
  42115. */
  42116. _mainSoundTrack: SoundTrack;
  42117. /**
  42118. * The main sound track played by the scene.
  42119. * It cotains your primary collection of sounds.
  42120. */
  42121. mainSoundTrack: SoundTrack;
  42122. /**
  42123. * The list of sound tracks added to the scene
  42124. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42125. */
  42126. soundTracks: Nullable<Array<SoundTrack>>;
  42127. /**
  42128. * Gets a sound using a given name
  42129. * @param name defines the name to search for
  42130. * @return the found sound or null if not found at all.
  42131. */
  42132. getSoundByName(name: string): Nullable<Sound>;
  42133. /**
  42134. * Gets or sets if audio support is enabled
  42135. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42136. */
  42137. audioEnabled: boolean;
  42138. /**
  42139. * Gets or sets if audio will be output to headphones
  42140. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42141. */
  42142. headphone: boolean;
  42143. /**
  42144. * Gets or sets custom audio listener position provider
  42145. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42146. */
  42147. audioListenerPositionProvider: Nullable<() => Vector3>;
  42148. /**
  42149. * Gets or sets a refresh rate when using 3D audio positioning
  42150. */
  42151. audioPositioningRefreshRate: number;
  42152. }
  42153. /**
  42154. * Defines the sound scene component responsible to manage any sounds
  42155. * in a given scene.
  42156. */
  42157. export class AudioSceneComponent implements ISceneSerializableComponent {
  42158. private static _CameraDirectionLH;
  42159. private static _CameraDirectionRH;
  42160. /**
  42161. * The component name helpfull to identify the component in the list of scene components.
  42162. */
  42163. readonly name: string;
  42164. /**
  42165. * The scene the component belongs to.
  42166. */
  42167. scene: Scene;
  42168. private _audioEnabled;
  42169. /**
  42170. * Gets whether audio is enabled or not.
  42171. * Please use related enable/disable method to switch state.
  42172. */
  42173. get audioEnabled(): boolean;
  42174. private _headphone;
  42175. /**
  42176. * Gets whether audio is outputing to headphone or not.
  42177. * Please use the according Switch methods to change output.
  42178. */
  42179. get headphone(): boolean;
  42180. /**
  42181. * Gets or sets a refresh rate when using 3D audio positioning
  42182. */
  42183. audioPositioningRefreshRate: number;
  42184. private _audioListenerPositionProvider;
  42185. /**
  42186. * Gets the current audio listener position provider
  42187. */
  42188. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  42189. /**
  42190. * Sets a custom listener position for all sounds in the scene
  42191. * By default, this is the position of the first active camera
  42192. */
  42193. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  42194. /**
  42195. * Creates a new instance of the component for the given scene
  42196. * @param scene Defines the scene to register the component in
  42197. */
  42198. constructor(scene: Scene);
  42199. /**
  42200. * Registers the component in a given scene
  42201. */
  42202. register(): void;
  42203. /**
  42204. * Rebuilds the elements related to this component in case of
  42205. * context lost for instance.
  42206. */
  42207. rebuild(): void;
  42208. /**
  42209. * Serializes the component data to the specified json object
  42210. * @param serializationObject The object to serialize to
  42211. */
  42212. serialize(serializationObject: any): void;
  42213. /**
  42214. * Adds all the elements from the container to the scene
  42215. * @param container the container holding the elements
  42216. */
  42217. addFromContainer(container: AbstractScene): void;
  42218. /**
  42219. * Removes all the elements in the container from the scene
  42220. * @param container contains the elements to remove
  42221. * @param dispose if the removed element should be disposed (default: false)
  42222. */
  42223. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  42224. /**
  42225. * Disposes the component and the associated ressources.
  42226. */
  42227. dispose(): void;
  42228. /**
  42229. * Disables audio in the associated scene.
  42230. */
  42231. disableAudio(): void;
  42232. /**
  42233. * Enables audio in the associated scene.
  42234. */
  42235. enableAudio(): void;
  42236. /**
  42237. * Switch audio to headphone output.
  42238. */
  42239. switchAudioModeForHeadphones(): void;
  42240. /**
  42241. * Switch audio to normal speakers.
  42242. */
  42243. switchAudioModeForNormalSpeakers(): void;
  42244. private _cachedCameraDirection;
  42245. private _cachedCameraPosition;
  42246. private _lastCheck;
  42247. private _afterRender;
  42248. }
  42249. }
  42250. declare module BABYLON {
  42251. /**
  42252. * Wraps one or more Sound objects and selects one with random weight for playback.
  42253. */
  42254. export class WeightedSound {
  42255. /** When true a Sound will be selected and played when the current playing Sound completes. */
  42256. loop: boolean;
  42257. private _coneInnerAngle;
  42258. private _coneOuterAngle;
  42259. private _volume;
  42260. /** A Sound is currently playing. */
  42261. isPlaying: boolean;
  42262. /** A Sound is currently paused. */
  42263. isPaused: boolean;
  42264. private _sounds;
  42265. private _weights;
  42266. private _currentIndex?;
  42267. /**
  42268. * Creates a new WeightedSound from the list of sounds given.
  42269. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  42270. * @param sounds Array of Sounds that will be selected from.
  42271. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  42272. */
  42273. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  42274. /**
  42275. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  42276. */
  42277. get directionalConeInnerAngle(): number;
  42278. /**
  42279. * The size of cone in degress for a directional sound in which there will be no attenuation.
  42280. */
  42281. set directionalConeInnerAngle(value: number);
  42282. /**
  42283. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42284. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42285. */
  42286. get directionalConeOuterAngle(): number;
  42287. /**
  42288. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42289. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42290. */
  42291. set directionalConeOuterAngle(value: number);
  42292. /**
  42293. * Playback volume.
  42294. */
  42295. get volume(): number;
  42296. /**
  42297. * Playback volume.
  42298. */
  42299. set volume(value: number);
  42300. private _onended;
  42301. /**
  42302. * Suspend playback
  42303. */
  42304. pause(): void;
  42305. /**
  42306. * Stop playback
  42307. */
  42308. stop(): void;
  42309. /**
  42310. * Start playback.
  42311. * @param startOffset Position the clip head at a specific time in seconds.
  42312. */
  42313. play(startOffset?: number): void;
  42314. }
  42315. }
  42316. declare module BABYLON {
  42317. /**
  42318. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  42319. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42320. */
  42321. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  42322. /**
  42323. * Gets the name of the behavior.
  42324. */
  42325. get name(): string;
  42326. /**
  42327. * The easing function used by animations
  42328. */
  42329. static EasingFunction: BackEase;
  42330. /**
  42331. * The easing mode used by animations
  42332. */
  42333. static EasingMode: number;
  42334. /**
  42335. * The duration of the animation, in milliseconds
  42336. */
  42337. transitionDuration: number;
  42338. /**
  42339. * Length of the distance animated by the transition when lower radius is reached
  42340. */
  42341. lowerRadiusTransitionRange: number;
  42342. /**
  42343. * Length of the distance animated by the transition when upper radius is reached
  42344. */
  42345. upperRadiusTransitionRange: number;
  42346. private _autoTransitionRange;
  42347. /**
  42348. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42349. */
  42350. get autoTransitionRange(): boolean;
  42351. /**
  42352. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42353. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  42354. */
  42355. set autoTransitionRange(value: boolean);
  42356. private _attachedCamera;
  42357. private _onAfterCheckInputsObserver;
  42358. private _onMeshTargetChangedObserver;
  42359. /**
  42360. * Initializes the behavior.
  42361. */
  42362. init(): void;
  42363. /**
  42364. * Attaches the behavior to its arc rotate camera.
  42365. * @param camera Defines the camera to attach the behavior to
  42366. */
  42367. attach(camera: ArcRotateCamera): void;
  42368. /**
  42369. * Detaches the behavior from its current arc rotate camera.
  42370. */
  42371. detach(): void;
  42372. private _radiusIsAnimating;
  42373. private _radiusBounceTransition;
  42374. private _animatables;
  42375. private _cachedWheelPrecision;
  42376. /**
  42377. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  42378. * @param radiusLimit The limit to check against.
  42379. * @return Bool to indicate if at limit.
  42380. */
  42381. private _isRadiusAtLimit;
  42382. /**
  42383. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  42384. * @param radiusDelta The delta by which to animate to. Can be negative.
  42385. */
  42386. private _applyBoundRadiusAnimation;
  42387. /**
  42388. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  42389. */
  42390. protected _clearAnimationLocks(): void;
  42391. /**
  42392. * Stops and removes all animations that have been applied to the camera
  42393. */
  42394. stopAllAnimations(): void;
  42395. }
  42396. }
  42397. declare module BABYLON {
  42398. /**
  42399. * 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.
  42400. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42401. */
  42402. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  42403. /**
  42404. * Gets the name of the behavior.
  42405. */
  42406. get name(): string;
  42407. private _mode;
  42408. private _radiusScale;
  42409. private _positionScale;
  42410. private _defaultElevation;
  42411. private _elevationReturnTime;
  42412. private _elevationReturnWaitTime;
  42413. private _zoomStopsAnimation;
  42414. private _framingTime;
  42415. /**
  42416. * The easing function used by animations
  42417. */
  42418. static EasingFunction: ExponentialEase;
  42419. /**
  42420. * The easing mode used by animations
  42421. */
  42422. static EasingMode: number;
  42423. /**
  42424. * Sets the current mode used by the behavior
  42425. */
  42426. set mode(mode: number);
  42427. /**
  42428. * Gets current mode used by the behavior.
  42429. */
  42430. get mode(): number;
  42431. /**
  42432. * Sets the scale applied to the radius (1 by default)
  42433. */
  42434. set radiusScale(radius: number);
  42435. /**
  42436. * Gets the scale applied to the radius
  42437. */
  42438. get radiusScale(): number;
  42439. /**
  42440. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42441. */
  42442. set positionScale(scale: number);
  42443. /**
  42444. * Gets 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. get positionScale(): number;
  42447. /**
  42448. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42449. * behaviour is triggered, in radians.
  42450. */
  42451. set defaultElevation(elevation: number);
  42452. /**
  42453. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42454. * behaviour is triggered, in radians.
  42455. */
  42456. get defaultElevation(): number;
  42457. /**
  42458. * Sets the time (in milliseconds) taken to return to the default beta position.
  42459. * Negative value indicates camera should not return to default.
  42460. */
  42461. set elevationReturnTime(speed: number);
  42462. /**
  42463. * Gets the time (in milliseconds) taken to return to the default beta position.
  42464. * Negative value indicates camera should not return to default.
  42465. */
  42466. get elevationReturnTime(): number;
  42467. /**
  42468. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42469. */
  42470. set elevationReturnWaitTime(time: number);
  42471. /**
  42472. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42473. */
  42474. get elevationReturnWaitTime(): number;
  42475. /**
  42476. * Sets the flag that indicates if user zooming should stop animation.
  42477. */
  42478. set zoomStopsAnimation(flag: boolean);
  42479. /**
  42480. * Gets the flag that indicates if user zooming should stop animation.
  42481. */
  42482. get zoomStopsAnimation(): boolean;
  42483. /**
  42484. * Sets the transition time when framing the mesh, in milliseconds
  42485. */
  42486. set framingTime(time: number);
  42487. /**
  42488. * Gets the transition time when framing the mesh, in milliseconds
  42489. */
  42490. get framingTime(): number;
  42491. /**
  42492. * Define if the behavior should automatically change the configured
  42493. * camera limits and sensibilities.
  42494. */
  42495. autoCorrectCameraLimitsAndSensibility: boolean;
  42496. private _onPrePointerObservableObserver;
  42497. private _onAfterCheckInputsObserver;
  42498. private _onMeshTargetChangedObserver;
  42499. private _attachedCamera;
  42500. private _isPointerDown;
  42501. private _lastInteractionTime;
  42502. /**
  42503. * Initializes the behavior.
  42504. */
  42505. init(): void;
  42506. /**
  42507. * Attaches the behavior to its arc rotate camera.
  42508. * @param camera Defines the camera to attach the behavior to
  42509. */
  42510. attach(camera: ArcRotateCamera): void;
  42511. /**
  42512. * Detaches the behavior from its current arc rotate camera.
  42513. */
  42514. detach(): void;
  42515. private _animatables;
  42516. private _betaIsAnimating;
  42517. private _betaTransition;
  42518. private _radiusTransition;
  42519. private _vectorTransition;
  42520. /**
  42521. * Targets the given mesh and updates zoom level accordingly.
  42522. * @param mesh The mesh to target.
  42523. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42524. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42525. */
  42526. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42527. /**
  42528. * Targets the given mesh with its children and updates zoom level accordingly.
  42529. * @param mesh The mesh to target.
  42530. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42531. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42532. */
  42533. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42534. /**
  42535. * Targets the given meshes with their children and updates zoom level accordingly.
  42536. * @param meshes The mesh to target.
  42537. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42538. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42539. */
  42540. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42541. /**
  42542. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  42543. * @param minimumWorld Determines the smaller position of the bounding box extend
  42544. * @param maximumWorld Determines the bigger position of the bounding box extend
  42545. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42546. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42547. */
  42548. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42549. /**
  42550. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  42551. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  42552. * frustum width.
  42553. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  42554. * to fully enclose the mesh in the viewing frustum.
  42555. */
  42556. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  42557. /**
  42558. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  42559. * is automatically returned to its default position (expected to be above ground plane).
  42560. */
  42561. private _maintainCameraAboveGround;
  42562. /**
  42563. * Returns the frustum slope based on the canvas ratio and camera FOV
  42564. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  42565. */
  42566. private _getFrustumSlope;
  42567. /**
  42568. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  42569. */
  42570. private _clearAnimationLocks;
  42571. /**
  42572. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42573. */
  42574. private _applyUserInteraction;
  42575. /**
  42576. * Stops and removes all animations that have been applied to the camera
  42577. */
  42578. stopAllAnimations(): void;
  42579. /**
  42580. * Gets a value indicating if the user is moving the camera
  42581. */
  42582. get isUserIsMoving(): boolean;
  42583. /**
  42584. * The camera can move all the way towards the mesh.
  42585. */
  42586. static IgnoreBoundsSizeMode: number;
  42587. /**
  42588. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  42589. */
  42590. static FitFrustumSidesMode: number;
  42591. }
  42592. }
  42593. declare module BABYLON {
  42594. /**
  42595. * Base class for Camera Pointer Inputs.
  42596. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  42597. * for example usage.
  42598. */
  42599. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  42600. /**
  42601. * Defines the camera the input is attached to.
  42602. */
  42603. abstract camera: Camera;
  42604. /**
  42605. * Whether keyboard modifier keys are pressed at time of last mouse event.
  42606. */
  42607. protected _altKey: boolean;
  42608. protected _ctrlKey: boolean;
  42609. protected _metaKey: boolean;
  42610. protected _shiftKey: boolean;
  42611. /**
  42612. * Which mouse buttons were pressed at time of last mouse event.
  42613. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  42614. */
  42615. protected _buttonsPressed: number;
  42616. /**
  42617. * Defines the buttons associated with the input to handle camera move.
  42618. */
  42619. buttons: number[];
  42620. /**
  42621. * Attach the input controls to a specific dom element to get the input from.
  42622. * @param element Defines the element the controls should be listened from
  42623. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42624. */
  42625. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42626. /**
  42627. * Detach the current controls from the specified dom element.
  42628. * @param element Defines the element to stop listening the inputs from
  42629. */
  42630. detachControl(element: Nullable<HTMLElement>): void;
  42631. /**
  42632. * Gets the class name of the current input.
  42633. * @returns the class name
  42634. */
  42635. getClassName(): string;
  42636. /**
  42637. * Get the friendly name associated with the input class.
  42638. * @returns the input friendly name
  42639. */
  42640. getSimpleName(): string;
  42641. /**
  42642. * Called on pointer POINTERDOUBLETAP event.
  42643. * Override this method to provide functionality on POINTERDOUBLETAP event.
  42644. */
  42645. protected onDoubleTap(type: string): void;
  42646. /**
  42647. * Called on pointer POINTERMOVE event if only a single touch is active.
  42648. * Override this method to provide functionality.
  42649. */
  42650. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42651. /**
  42652. * Called on pointer POINTERMOVE event if multiple touches are active.
  42653. * Override this method to provide functionality.
  42654. */
  42655. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42656. /**
  42657. * Called on JS contextmenu event.
  42658. * Override this method to provide functionality.
  42659. */
  42660. protected onContextMenu(evt: PointerEvent): void;
  42661. /**
  42662. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42663. * press.
  42664. * Override this method to provide functionality.
  42665. */
  42666. protected onButtonDown(evt: PointerEvent): void;
  42667. /**
  42668. * Called each time a new POINTERUP event occurs. Ie, for each button
  42669. * release.
  42670. * Override this method to provide functionality.
  42671. */
  42672. protected onButtonUp(evt: PointerEvent): void;
  42673. /**
  42674. * Called when window becomes inactive.
  42675. * Override this method to provide functionality.
  42676. */
  42677. protected onLostFocus(): void;
  42678. private _pointerInput;
  42679. private _observer;
  42680. private _onLostFocus;
  42681. private pointA;
  42682. private pointB;
  42683. }
  42684. }
  42685. declare module BABYLON {
  42686. /**
  42687. * Manage the pointers inputs to control an arc rotate camera.
  42688. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42689. */
  42690. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  42691. /**
  42692. * Defines the camera the input is attached to.
  42693. */
  42694. camera: ArcRotateCamera;
  42695. /**
  42696. * Gets the class name of the current input.
  42697. * @returns the class name
  42698. */
  42699. getClassName(): string;
  42700. /**
  42701. * Defines the buttons associated with the input to handle camera move.
  42702. */
  42703. buttons: number[];
  42704. /**
  42705. * Defines the pointer angular sensibility along the X axis or how fast is
  42706. * the camera rotating.
  42707. */
  42708. angularSensibilityX: number;
  42709. /**
  42710. * Defines the pointer angular sensibility along the Y axis or how fast is
  42711. * the camera rotating.
  42712. */
  42713. angularSensibilityY: number;
  42714. /**
  42715. * Defines the pointer pinch precision or how fast is the camera zooming.
  42716. */
  42717. pinchPrecision: number;
  42718. /**
  42719. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  42720. * from 0.
  42721. * It defines the percentage of current camera.radius to use as delta when
  42722. * pinch zoom is used.
  42723. */
  42724. pinchDeltaPercentage: number;
  42725. /**
  42726. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42727. * that any object in the plane at the camera's target point will scale
  42728. * perfectly with finger motion.
  42729. * Overrides pinchDeltaPercentage and pinchPrecision.
  42730. */
  42731. useNaturalPinchZoom: boolean;
  42732. /**
  42733. * Defines the pointer panning sensibility or how fast is the camera moving.
  42734. */
  42735. panningSensibility: number;
  42736. /**
  42737. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  42738. */
  42739. multiTouchPanning: boolean;
  42740. /**
  42741. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  42742. * zoom (pinch) through multitouch.
  42743. */
  42744. multiTouchPanAndZoom: boolean;
  42745. /**
  42746. * Revers pinch action direction.
  42747. */
  42748. pinchInwards: boolean;
  42749. private _isPanClick;
  42750. private _twoFingerActivityCount;
  42751. private _isPinching;
  42752. /**
  42753. * Called on pointer POINTERMOVE event if only a single touch is active.
  42754. */
  42755. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42756. /**
  42757. * Called on pointer POINTERDOUBLETAP event.
  42758. */
  42759. protected onDoubleTap(type: string): void;
  42760. /**
  42761. * Called on pointer POINTERMOVE event if multiple touches are active.
  42762. */
  42763. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42764. /**
  42765. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42766. * press.
  42767. */
  42768. protected onButtonDown(evt: PointerEvent): void;
  42769. /**
  42770. * Called each time a new POINTERUP event occurs. Ie, for each button
  42771. * release.
  42772. */
  42773. protected onButtonUp(evt: PointerEvent): void;
  42774. /**
  42775. * Called when window becomes inactive.
  42776. */
  42777. protected onLostFocus(): void;
  42778. }
  42779. }
  42780. declare module BABYLON {
  42781. /**
  42782. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  42783. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42784. */
  42785. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  42786. /**
  42787. * Defines the camera the input is attached to.
  42788. */
  42789. camera: ArcRotateCamera;
  42790. /**
  42791. * Defines the list of key codes associated with the up action (increase alpha)
  42792. */
  42793. keysUp: number[];
  42794. /**
  42795. * Defines the list of key codes associated with the down action (decrease alpha)
  42796. */
  42797. keysDown: number[];
  42798. /**
  42799. * Defines the list of key codes associated with the left action (increase beta)
  42800. */
  42801. keysLeft: number[];
  42802. /**
  42803. * Defines the list of key codes associated with the right action (decrease beta)
  42804. */
  42805. keysRight: number[];
  42806. /**
  42807. * Defines the list of key codes associated with the reset action.
  42808. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  42809. */
  42810. keysReset: number[];
  42811. /**
  42812. * Defines the panning sensibility of the inputs.
  42813. * (How fast is the camera panning)
  42814. */
  42815. panningSensibility: number;
  42816. /**
  42817. * Defines the zooming sensibility of the inputs.
  42818. * (How fast is the camera zooming)
  42819. */
  42820. zoomingSensibility: number;
  42821. /**
  42822. * Defines whether maintaining the alt key down switch the movement mode from
  42823. * orientation to zoom.
  42824. */
  42825. useAltToZoom: boolean;
  42826. /**
  42827. * Rotation speed of the camera
  42828. */
  42829. angularSpeed: number;
  42830. private _keys;
  42831. private _ctrlPressed;
  42832. private _altPressed;
  42833. private _onCanvasBlurObserver;
  42834. private _onKeyboardObserver;
  42835. private _engine;
  42836. private _scene;
  42837. /**
  42838. * Attach the input controls to a specific dom element to get the input from.
  42839. * @param element Defines the element the controls should be listened from
  42840. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42841. */
  42842. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42843. /**
  42844. * Detach the current controls from the specified dom element.
  42845. * @param element Defines the element to stop listening the inputs from
  42846. */
  42847. detachControl(element: Nullable<HTMLElement>): void;
  42848. /**
  42849. * Update the current camera state depending on the inputs that have been used this frame.
  42850. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42851. */
  42852. checkInputs(): void;
  42853. /**
  42854. * Gets the class name of the current intput.
  42855. * @returns the class name
  42856. */
  42857. getClassName(): string;
  42858. /**
  42859. * Get the friendly name associated with the input class.
  42860. * @returns the input friendly name
  42861. */
  42862. getSimpleName(): string;
  42863. }
  42864. }
  42865. declare module BABYLON {
  42866. /**
  42867. * Manage the mouse wheel inputs to control an arc rotate camera.
  42868. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42869. */
  42870. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  42871. /**
  42872. * Defines the camera the input is attached to.
  42873. */
  42874. camera: ArcRotateCamera;
  42875. /**
  42876. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42877. */
  42878. wheelPrecision: number;
  42879. /**
  42880. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  42881. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  42882. */
  42883. wheelDeltaPercentage: number;
  42884. private _wheel;
  42885. private _observer;
  42886. private computeDeltaFromMouseWheelLegacyEvent;
  42887. /**
  42888. * Attach the input controls to a specific dom element to get the input from.
  42889. * @param element Defines the element the controls should be listened from
  42890. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42891. */
  42892. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42893. /**
  42894. * Detach the current controls from the specified dom element.
  42895. * @param element Defines the element to stop listening the inputs from
  42896. */
  42897. detachControl(element: Nullable<HTMLElement>): void;
  42898. /**
  42899. * Gets the class name of the current intput.
  42900. * @returns the class name
  42901. */
  42902. getClassName(): string;
  42903. /**
  42904. * Get the friendly name associated with the input class.
  42905. * @returns the input friendly name
  42906. */
  42907. getSimpleName(): string;
  42908. }
  42909. }
  42910. declare module BABYLON {
  42911. /**
  42912. * Default Inputs manager for the ArcRotateCamera.
  42913. * It groups all the default supported inputs for ease of use.
  42914. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42915. */
  42916. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  42917. /**
  42918. * Instantiates a new ArcRotateCameraInputsManager.
  42919. * @param camera Defines the camera the inputs belong to
  42920. */
  42921. constructor(camera: ArcRotateCamera);
  42922. /**
  42923. * Add mouse wheel input support to the input manager.
  42924. * @returns the current input manager
  42925. */
  42926. addMouseWheel(): ArcRotateCameraInputsManager;
  42927. /**
  42928. * Add pointers input support to the input manager.
  42929. * @returns the current input manager
  42930. */
  42931. addPointers(): ArcRotateCameraInputsManager;
  42932. /**
  42933. * Add keyboard input support to the input manager.
  42934. * @returns the current input manager
  42935. */
  42936. addKeyboard(): ArcRotateCameraInputsManager;
  42937. }
  42938. }
  42939. declare module BABYLON {
  42940. /**
  42941. * This represents an orbital type of camera.
  42942. *
  42943. * 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.
  42944. * 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.
  42945. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  42946. */
  42947. export class ArcRotateCamera extends TargetCamera {
  42948. /**
  42949. * Defines the rotation angle of the camera along the longitudinal axis.
  42950. */
  42951. alpha: number;
  42952. /**
  42953. * Defines the rotation angle of the camera along the latitudinal axis.
  42954. */
  42955. beta: number;
  42956. /**
  42957. * Defines the radius of the camera from it s target point.
  42958. */
  42959. radius: number;
  42960. protected _target: Vector3;
  42961. protected _targetHost: Nullable<AbstractMesh>;
  42962. /**
  42963. * Defines the target point of the camera.
  42964. * The camera looks towards it form the radius distance.
  42965. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  42966. */
  42967. get target(): Vector3;
  42968. set target(value: Vector3);
  42969. /**
  42970. * Define the current local position of the camera in the scene
  42971. */
  42972. get position(): Vector3;
  42973. set position(newPosition: Vector3);
  42974. protected _upToYMatrix: Matrix;
  42975. protected _YToUpMatrix: Matrix;
  42976. /**
  42977. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  42978. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  42979. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  42980. */
  42981. set upVector(vec: Vector3);
  42982. get upVector(): Vector3;
  42983. /**
  42984. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  42985. */
  42986. setMatUp(): void;
  42987. /**
  42988. * Current inertia value on the longitudinal axis.
  42989. * The bigger this number the longer it will take for the camera to stop.
  42990. */
  42991. inertialAlphaOffset: number;
  42992. /**
  42993. * Current inertia value on the latitudinal axis.
  42994. * The bigger this number the longer it will take for the camera to stop.
  42995. */
  42996. inertialBetaOffset: number;
  42997. /**
  42998. * Current inertia value on the radius axis.
  42999. * The bigger this number the longer it will take for the camera to stop.
  43000. */
  43001. inertialRadiusOffset: number;
  43002. /**
  43003. * Minimum allowed angle on the longitudinal axis.
  43004. * This can help limiting how the Camera is able to move in the scene.
  43005. */
  43006. lowerAlphaLimit: Nullable<number>;
  43007. /**
  43008. * Maximum allowed angle on the longitudinal axis.
  43009. * This can help limiting how the Camera is able to move in the scene.
  43010. */
  43011. upperAlphaLimit: Nullable<number>;
  43012. /**
  43013. * Minimum allowed angle on the latitudinal axis.
  43014. * This can help limiting how the Camera is able to move in the scene.
  43015. */
  43016. lowerBetaLimit: number;
  43017. /**
  43018. * Maximum allowed angle on the latitudinal axis.
  43019. * This can help limiting how the Camera is able to move in the scene.
  43020. */
  43021. upperBetaLimit: number;
  43022. /**
  43023. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  43024. * This can help limiting how the Camera is able to move in the scene.
  43025. */
  43026. lowerRadiusLimit: Nullable<number>;
  43027. /**
  43028. * Maximum allowed distance of the camera to the target (The camera can not get further).
  43029. * This can help limiting how the Camera is able to move in the scene.
  43030. */
  43031. upperRadiusLimit: Nullable<number>;
  43032. /**
  43033. * Defines the current inertia value used during panning of the camera along the X axis.
  43034. */
  43035. inertialPanningX: number;
  43036. /**
  43037. * Defines the current inertia value used during panning of the camera along the Y axis.
  43038. */
  43039. inertialPanningY: number;
  43040. /**
  43041. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  43042. * Basically if your fingers moves away from more than this distance you will be considered
  43043. * in pinch mode.
  43044. */
  43045. pinchToPanMaxDistance: number;
  43046. /**
  43047. * Defines the maximum distance the camera can pan.
  43048. * This could help keeping the cammera always in your scene.
  43049. */
  43050. panningDistanceLimit: Nullable<number>;
  43051. /**
  43052. * Defines the target of the camera before paning.
  43053. */
  43054. panningOriginTarget: Vector3;
  43055. /**
  43056. * Defines the value of the inertia used during panning.
  43057. * 0 would mean stop inertia and one would mean no decelleration at all.
  43058. */
  43059. panningInertia: number;
  43060. /**
  43061. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  43062. */
  43063. get angularSensibilityX(): number;
  43064. set angularSensibilityX(value: number);
  43065. /**
  43066. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  43067. */
  43068. get angularSensibilityY(): number;
  43069. set angularSensibilityY(value: number);
  43070. /**
  43071. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  43072. */
  43073. get pinchPrecision(): number;
  43074. set pinchPrecision(value: number);
  43075. /**
  43076. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  43077. * It will be used instead of pinchDeltaPrecision if different from 0.
  43078. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43079. */
  43080. get pinchDeltaPercentage(): number;
  43081. set pinchDeltaPercentage(value: number);
  43082. /**
  43083. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  43084. * and pinch delta percentage.
  43085. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  43086. * that any object in the plane at the camera's target point will scale
  43087. * perfectly with finger motion.
  43088. */
  43089. get useNaturalPinchZoom(): boolean;
  43090. set useNaturalPinchZoom(value: boolean);
  43091. /**
  43092. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  43093. */
  43094. get panningSensibility(): number;
  43095. set panningSensibility(value: number);
  43096. /**
  43097. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  43098. */
  43099. get keysUp(): number[];
  43100. set keysUp(value: number[]);
  43101. /**
  43102. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  43103. */
  43104. get keysDown(): number[];
  43105. set keysDown(value: number[]);
  43106. /**
  43107. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  43108. */
  43109. get keysLeft(): number[];
  43110. set keysLeft(value: number[]);
  43111. /**
  43112. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  43113. */
  43114. get keysRight(): number[];
  43115. set keysRight(value: number[]);
  43116. /**
  43117. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  43118. */
  43119. get wheelPrecision(): number;
  43120. set wheelPrecision(value: number);
  43121. /**
  43122. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  43123. * It will be used instead of pinchDeltaPrecision if different from 0.
  43124. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43125. */
  43126. get wheelDeltaPercentage(): number;
  43127. set wheelDeltaPercentage(value: number);
  43128. /**
  43129. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  43130. */
  43131. zoomOnFactor: number;
  43132. /**
  43133. * Defines a screen offset for the camera position.
  43134. */
  43135. targetScreenOffset: Vector2;
  43136. /**
  43137. * Allows the camera to be completely reversed.
  43138. * If false the camera can not arrive upside down.
  43139. */
  43140. allowUpsideDown: boolean;
  43141. /**
  43142. * Define if double tap/click is used to restore the previously saved state of the camera.
  43143. */
  43144. useInputToRestoreState: boolean;
  43145. /** @hidden */
  43146. _viewMatrix: Matrix;
  43147. /** @hidden */
  43148. _useCtrlForPanning: boolean;
  43149. /** @hidden */
  43150. _panningMouseButton: number;
  43151. /**
  43152. * Defines the input associated to the camera.
  43153. */
  43154. inputs: ArcRotateCameraInputsManager;
  43155. /** @hidden */
  43156. _reset: () => void;
  43157. /**
  43158. * Defines the allowed panning axis.
  43159. */
  43160. panningAxis: Vector3;
  43161. protected _localDirection: Vector3;
  43162. protected _transformedDirection: Vector3;
  43163. private _bouncingBehavior;
  43164. /**
  43165. * Gets the bouncing behavior of the camera if it has been enabled.
  43166. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43167. */
  43168. get bouncingBehavior(): Nullable<BouncingBehavior>;
  43169. /**
  43170. * Defines if the bouncing behavior of the camera is enabled on the camera.
  43171. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43172. */
  43173. get useBouncingBehavior(): boolean;
  43174. set useBouncingBehavior(value: boolean);
  43175. private _framingBehavior;
  43176. /**
  43177. * Gets the framing behavior of the camera if it has been enabled.
  43178. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43179. */
  43180. get framingBehavior(): Nullable<FramingBehavior>;
  43181. /**
  43182. * Defines if the framing behavior of the camera is enabled on the camera.
  43183. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43184. */
  43185. get useFramingBehavior(): boolean;
  43186. set useFramingBehavior(value: boolean);
  43187. private _autoRotationBehavior;
  43188. /**
  43189. * Gets the auto rotation behavior of the camera if it has been enabled.
  43190. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43191. */
  43192. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  43193. /**
  43194. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  43195. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43196. */
  43197. get useAutoRotationBehavior(): boolean;
  43198. set useAutoRotationBehavior(value: boolean);
  43199. /**
  43200. * Observable triggered when the mesh target has been changed on the camera.
  43201. */
  43202. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  43203. /**
  43204. * Event raised when the camera is colliding with a mesh.
  43205. */
  43206. onCollide: (collidedMesh: AbstractMesh) => void;
  43207. /**
  43208. * Defines whether the camera should check collision with the objects oh the scene.
  43209. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  43210. */
  43211. checkCollisions: boolean;
  43212. /**
  43213. * Defines the collision radius of the camera.
  43214. * This simulates a sphere around the camera.
  43215. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43216. */
  43217. collisionRadius: Vector3;
  43218. protected _collider: Collider;
  43219. protected _previousPosition: Vector3;
  43220. protected _collisionVelocity: Vector3;
  43221. protected _newPosition: Vector3;
  43222. protected _previousAlpha: number;
  43223. protected _previousBeta: number;
  43224. protected _previousRadius: number;
  43225. protected _collisionTriggered: boolean;
  43226. protected _targetBoundingCenter: Nullable<Vector3>;
  43227. private _computationVector;
  43228. /**
  43229. * Instantiates a new ArcRotateCamera in a given scene
  43230. * @param name Defines the name of the camera
  43231. * @param alpha Defines the camera rotation along the logitudinal axis
  43232. * @param beta Defines the camera rotation along the latitudinal axis
  43233. * @param radius Defines the camera distance from its target
  43234. * @param target Defines the camera target
  43235. * @param scene Defines the scene the camera belongs to
  43236. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  43237. */
  43238. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43239. /** @hidden */
  43240. _initCache(): void;
  43241. /** @hidden */
  43242. _updateCache(ignoreParentClass?: boolean): void;
  43243. protected _getTargetPosition(): Vector3;
  43244. private _storedAlpha;
  43245. private _storedBeta;
  43246. private _storedRadius;
  43247. private _storedTarget;
  43248. private _storedTargetScreenOffset;
  43249. /**
  43250. * Stores the current state of the camera (alpha, beta, radius and target)
  43251. * @returns the camera itself
  43252. */
  43253. storeState(): Camera;
  43254. /**
  43255. * @hidden
  43256. * Restored camera state. You must call storeState() first
  43257. */
  43258. _restoreStateValues(): boolean;
  43259. /** @hidden */
  43260. _isSynchronizedViewMatrix(): boolean;
  43261. /**
  43262. * Attached controls to the current camera.
  43263. * @param element Defines the element the controls should be listened from
  43264. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43265. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  43266. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  43267. */
  43268. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  43269. /**
  43270. * Detach the current controls from the camera.
  43271. * The camera will stop reacting to inputs.
  43272. * @param element Defines the element to stop listening the inputs from
  43273. */
  43274. detachControl(element: HTMLElement): void;
  43275. /** @hidden */
  43276. _checkInputs(): void;
  43277. protected _checkLimits(): void;
  43278. /**
  43279. * Rebuilds angles (alpha, beta) and radius from the give position and target
  43280. */
  43281. rebuildAnglesAndRadius(): void;
  43282. /**
  43283. * Use a position to define the current camera related information like alpha, beta and radius
  43284. * @param position Defines the position to set the camera at
  43285. */
  43286. setPosition(position: Vector3): void;
  43287. /**
  43288. * Defines the target the camera should look at.
  43289. * This will automatically adapt alpha beta and radius to fit within the new target.
  43290. * @param target Defines the new target as a Vector or a mesh
  43291. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  43292. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  43293. */
  43294. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  43295. /** @hidden */
  43296. _getViewMatrix(): Matrix;
  43297. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  43298. /**
  43299. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  43300. * @param meshes Defines the mesh to zoom on
  43301. * @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)
  43302. */
  43303. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  43304. /**
  43305. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  43306. * The target will be changed but the radius
  43307. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  43308. * @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)
  43309. */
  43310. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  43311. min: Vector3;
  43312. max: Vector3;
  43313. distance: number;
  43314. }, doNotUpdateMaxZ?: boolean): void;
  43315. /**
  43316. * @override
  43317. * Override Camera.createRigCamera
  43318. */
  43319. createRigCamera(name: string, cameraIndex: number): Camera;
  43320. /**
  43321. * @hidden
  43322. * @override
  43323. * Override Camera._updateRigCameras
  43324. */
  43325. _updateRigCameras(): void;
  43326. /**
  43327. * Destroy the camera and release the current resources hold by it.
  43328. */
  43329. dispose(): void;
  43330. /**
  43331. * Gets the current object class name.
  43332. * @return the class name
  43333. */
  43334. getClassName(): string;
  43335. }
  43336. }
  43337. declare module BABYLON {
  43338. /**
  43339. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  43340. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43341. */
  43342. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  43343. /**
  43344. * Gets the name of the behavior.
  43345. */
  43346. get name(): string;
  43347. private _zoomStopsAnimation;
  43348. private _idleRotationSpeed;
  43349. private _idleRotationWaitTime;
  43350. private _idleRotationSpinupTime;
  43351. /**
  43352. * Sets the flag that indicates if user zooming should stop animation.
  43353. */
  43354. set zoomStopsAnimation(flag: boolean);
  43355. /**
  43356. * Gets the flag that indicates if user zooming should stop animation.
  43357. */
  43358. get zoomStopsAnimation(): boolean;
  43359. /**
  43360. * Sets the default speed at which the camera rotates around the model.
  43361. */
  43362. set idleRotationSpeed(speed: number);
  43363. /**
  43364. * Gets the default speed at which the camera rotates around the model.
  43365. */
  43366. get idleRotationSpeed(): number;
  43367. /**
  43368. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  43369. */
  43370. set idleRotationWaitTime(time: number);
  43371. /**
  43372. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  43373. */
  43374. get idleRotationWaitTime(): number;
  43375. /**
  43376. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43377. */
  43378. set idleRotationSpinupTime(time: number);
  43379. /**
  43380. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43381. */
  43382. get idleRotationSpinupTime(): number;
  43383. /**
  43384. * Gets a value indicating if the camera is currently rotating because of this behavior
  43385. */
  43386. get rotationInProgress(): boolean;
  43387. private _onPrePointerObservableObserver;
  43388. private _onAfterCheckInputsObserver;
  43389. private _attachedCamera;
  43390. private _isPointerDown;
  43391. private _lastFrameTime;
  43392. private _lastInteractionTime;
  43393. private _cameraRotationSpeed;
  43394. /**
  43395. * Initializes the behavior.
  43396. */
  43397. init(): void;
  43398. /**
  43399. * Attaches the behavior to its arc rotate camera.
  43400. * @param camera Defines the camera to attach the behavior to
  43401. */
  43402. attach(camera: ArcRotateCamera): void;
  43403. /**
  43404. * Detaches the behavior from its current arc rotate camera.
  43405. */
  43406. detach(): void;
  43407. /**
  43408. * Returns true if user is scrolling.
  43409. * @return true if user is scrolling.
  43410. */
  43411. private _userIsZooming;
  43412. private _lastFrameRadius;
  43413. private _shouldAnimationStopForInteraction;
  43414. /**
  43415. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43416. */
  43417. private _applyUserInteraction;
  43418. private _userIsMoving;
  43419. }
  43420. }
  43421. declare module BABYLON {
  43422. /**
  43423. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  43424. */
  43425. export class AttachToBoxBehavior implements Behavior<Mesh> {
  43426. private ui;
  43427. /**
  43428. * The name of the behavior
  43429. */
  43430. name: string;
  43431. /**
  43432. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  43433. */
  43434. distanceAwayFromFace: number;
  43435. /**
  43436. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  43437. */
  43438. distanceAwayFromBottomOfFace: number;
  43439. private _faceVectors;
  43440. private _target;
  43441. private _scene;
  43442. private _onRenderObserver;
  43443. private _tmpMatrix;
  43444. private _tmpVector;
  43445. /**
  43446. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  43447. * @param ui The transform node that should be attched to the mesh
  43448. */
  43449. constructor(ui: TransformNode);
  43450. /**
  43451. * Initializes the behavior
  43452. */
  43453. init(): void;
  43454. private _closestFace;
  43455. private _zeroVector;
  43456. private _lookAtTmpMatrix;
  43457. private _lookAtToRef;
  43458. /**
  43459. * Attaches the AttachToBoxBehavior to the passed in mesh
  43460. * @param target The mesh that the specified node will be attached to
  43461. */
  43462. attach(target: Mesh): void;
  43463. /**
  43464. * Detaches the behavior from the mesh
  43465. */
  43466. detach(): void;
  43467. }
  43468. }
  43469. declare module BABYLON {
  43470. /**
  43471. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  43472. */
  43473. export class FadeInOutBehavior implements Behavior<Mesh> {
  43474. /**
  43475. * Time in milliseconds to delay before fading in (Default: 0)
  43476. */
  43477. delay: number;
  43478. /**
  43479. * Time in milliseconds for the mesh to fade in (Default: 300)
  43480. */
  43481. fadeInTime: number;
  43482. private _millisecondsPerFrame;
  43483. private _hovered;
  43484. private _hoverValue;
  43485. private _ownerNode;
  43486. /**
  43487. * Instatiates the FadeInOutBehavior
  43488. */
  43489. constructor();
  43490. /**
  43491. * The name of the behavior
  43492. */
  43493. get name(): string;
  43494. /**
  43495. * Initializes the behavior
  43496. */
  43497. init(): void;
  43498. /**
  43499. * Attaches the fade behavior on the passed in mesh
  43500. * @param ownerNode The mesh that will be faded in/out once attached
  43501. */
  43502. attach(ownerNode: Mesh): void;
  43503. /**
  43504. * Detaches the behavior from the mesh
  43505. */
  43506. detach(): void;
  43507. /**
  43508. * Triggers the mesh to begin fading in or out
  43509. * @param value if the object should fade in or out (true to fade in)
  43510. */
  43511. fadeIn(value: boolean): void;
  43512. private _update;
  43513. private _setAllVisibility;
  43514. }
  43515. }
  43516. declare module BABYLON {
  43517. /**
  43518. * Class containing a set of static utilities functions for managing Pivots
  43519. * @hidden
  43520. */
  43521. export class PivotTools {
  43522. private static _PivotCached;
  43523. private static _OldPivotPoint;
  43524. private static _PivotTranslation;
  43525. private static _PivotTmpVector;
  43526. private static _PivotPostMultiplyPivotMatrix;
  43527. /** @hidden */
  43528. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  43529. /** @hidden */
  43530. static _RestorePivotPoint(mesh: AbstractMesh): void;
  43531. }
  43532. }
  43533. declare module BABYLON {
  43534. /**
  43535. * Class containing static functions to help procedurally build meshes
  43536. */
  43537. export class PlaneBuilder {
  43538. /**
  43539. * Creates a plane mesh
  43540. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  43541. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  43542. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  43543. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43544. * * 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
  43545. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43546. * @param name defines the name of the mesh
  43547. * @param options defines the options used to create the mesh
  43548. * @param scene defines the hosting scene
  43549. * @returns the plane mesh
  43550. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  43551. */
  43552. static CreatePlane(name: string, options: {
  43553. size?: number;
  43554. width?: number;
  43555. height?: number;
  43556. sideOrientation?: number;
  43557. frontUVs?: Vector4;
  43558. backUVs?: Vector4;
  43559. updatable?: boolean;
  43560. sourcePlane?: Plane;
  43561. }, scene?: Nullable<Scene>): Mesh;
  43562. }
  43563. }
  43564. declare module BABYLON {
  43565. /**
  43566. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  43567. */
  43568. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  43569. private static _AnyMouseID;
  43570. /**
  43571. * Abstract mesh the behavior is set on
  43572. */
  43573. attachedNode: AbstractMesh;
  43574. private _dragPlane;
  43575. private _scene;
  43576. private _pointerObserver;
  43577. private _beforeRenderObserver;
  43578. private static _planeScene;
  43579. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  43580. /**
  43581. * 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)
  43582. */
  43583. maxDragAngle: number;
  43584. /**
  43585. * @hidden
  43586. */
  43587. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  43588. /**
  43589. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43590. */
  43591. currentDraggingPointerID: number;
  43592. /**
  43593. * The last position where the pointer hit the drag plane in world space
  43594. */
  43595. lastDragPosition: Vector3;
  43596. /**
  43597. * If the behavior is currently in a dragging state
  43598. */
  43599. dragging: boolean;
  43600. /**
  43601. * 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)
  43602. */
  43603. dragDeltaRatio: number;
  43604. /**
  43605. * If the drag plane orientation should be updated during the dragging (Default: true)
  43606. */
  43607. updateDragPlane: boolean;
  43608. private _debugMode;
  43609. private _moving;
  43610. /**
  43611. * Fires each time the attached mesh is dragged with the pointer
  43612. * * delta between last drag position and current drag position in world space
  43613. * * dragDistance along the drag axis
  43614. * * dragPlaneNormal normal of the current drag plane used during the drag
  43615. * * dragPlanePoint in world space where the drag intersects the drag plane
  43616. */
  43617. onDragObservable: Observable<{
  43618. delta: Vector3;
  43619. dragPlanePoint: Vector3;
  43620. dragPlaneNormal: Vector3;
  43621. dragDistance: number;
  43622. pointerId: number;
  43623. }>;
  43624. /**
  43625. * Fires each time a drag begins (eg. mouse down on mesh)
  43626. */
  43627. onDragStartObservable: Observable<{
  43628. dragPlanePoint: Vector3;
  43629. pointerId: number;
  43630. }>;
  43631. /**
  43632. * Fires each time a drag ends (eg. mouse release after drag)
  43633. */
  43634. onDragEndObservable: Observable<{
  43635. dragPlanePoint: Vector3;
  43636. pointerId: number;
  43637. }>;
  43638. /**
  43639. * If the attached mesh should be moved when dragged
  43640. */
  43641. moveAttached: boolean;
  43642. /**
  43643. * If the drag behavior will react to drag events (Default: true)
  43644. */
  43645. enabled: boolean;
  43646. /**
  43647. * If pointer events should start and release the drag (Default: true)
  43648. */
  43649. startAndReleaseDragOnPointerEvents: boolean;
  43650. /**
  43651. * If camera controls should be detached during the drag
  43652. */
  43653. detachCameraControls: boolean;
  43654. /**
  43655. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  43656. */
  43657. useObjectOrientationForDragging: boolean;
  43658. private _options;
  43659. /**
  43660. * Gets the options used by the behavior
  43661. */
  43662. get options(): {
  43663. dragAxis?: Vector3;
  43664. dragPlaneNormal?: Vector3;
  43665. };
  43666. /**
  43667. * Sets the options used by the behavior
  43668. */
  43669. set options(options: {
  43670. dragAxis?: Vector3;
  43671. dragPlaneNormal?: Vector3;
  43672. });
  43673. /**
  43674. * Creates a pointer drag behavior that can be attached to a mesh
  43675. * @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)
  43676. */
  43677. constructor(options?: {
  43678. dragAxis?: Vector3;
  43679. dragPlaneNormal?: Vector3;
  43680. });
  43681. /**
  43682. * Predicate to determine if it is valid to move the object to a new position when it is moved
  43683. */
  43684. validateDrag: (targetPosition: Vector3) => boolean;
  43685. /**
  43686. * The name of the behavior
  43687. */
  43688. get name(): string;
  43689. /**
  43690. * Initializes the behavior
  43691. */
  43692. init(): void;
  43693. private _tmpVector;
  43694. private _alternatePickedPoint;
  43695. private _worldDragAxis;
  43696. private _targetPosition;
  43697. private _attachedElement;
  43698. /**
  43699. * Attaches the drag behavior the passed in mesh
  43700. * @param ownerNode The mesh that will be dragged around once attached
  43701. * @param predicate Predicate to use for pick filtering
  43702. */
  43703. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  43704. /**
  43705. * Force relase the drag action by code.
  43706. */
  43707. releaseDrag(): void;
  43708. private _startDragRay;
  43709. private _lastPointerRay;
  43710. /**
  43711. * Simulates the start of a pointer drag event on the behavior
  43712. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  43713. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  43714. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  43715. */
  43716. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  43717. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  43718. private _dragDelta;
  43719. protected _moveDrag(ray: Ray): void;
  43720. private _pickWithRayOnDragPlane;
  43721. private _pointA;
  43722. private _pointC;
  43723. private _localAxis;
  43724. private _lookAt;
  43725. private _updateDragPlanePosition;
  43726. /**
  43727. * Detaches the behavior from the mesh
  43728. */
  43729. detach(): void;
  43730. }
  43731. }
  43732. declare module BABYLON {
  43733. /**
  43734. * A behavior that when attached to a mesh will allow the mesh to be scaled
  43735. */
  43736. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  43737. private _dragBehaviorA;
  43738. private _dragBehaviorB;
  43739. private _startDistance;
  43740. private _initialScale;
  43741. private _targetScale;
  43742. private _ownerNode;
  43743. private _sceneRenderObserver;
  43744. /**
  43745. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  43746. */
  43747. constructor();
  43748. /**
  43749. * The name of the behavior
  43750. */
  43751. get name(): string;
  43752. /**
  43753. * Initializes the behavior
  43754. */
  43755. init(): void;
  43756. private _getCurrentDistance;
  43757. /**
  43758. * Attaches the scale behavior the passed in mesh
  43759. * @param ownerNode The mesh that will be scaled around once attached
  43760. */
  43761. attach(ownerNode: Mesh): void;
  43762. /**
  43763. * Detaches the behavior from the mesh
  43764. */
  43765. detach(): void;
  43766. }
  43767. }
  43768. declare module BABYLON {
  43769. /**
  43770. * 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
  43771. */
  43772. export class SixDofDragBehavior implements Behavior<Mesh> {
  43773. private static _virtualScene;
  43774. private _ownerNode;
  43775. private _sceneRenderObserver;
  43776. private _scene;
  43777. private _targetPosition;
  43778. private _virtualOriginMesh;
  43779. private _virtualDragMesh;
  43780. private _pointerObserver;
  43781. private _moving;
  43782. private _startingOrientation;
  43783. private _attachedElement;
  43784. /**
  43785. * 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)
  43786. */
  43787. private zDragFactor;
  43788. /**
  43789. * If the object should rotate to face the drag origin
  43790. */
  43791. rotateDraggedObject: boolean;
  43792. /**
  43793. * If the behavior is currently in a dragging state
  43794. */
  43795. dragging: boolean;
  43796. /**
  43797. * 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)
  43798. */
  43799. dragDeltaRatio: number;
  43800. /**
  43801. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43802. */
  43803. currentDraggingPointerID: number;
  43804. /**
  43805. * If camera controls should be detached during the drag
  43806. */
  43807. detachCameraControls: boolean;
  43808. /**
  43809. * Fires each time a drag starts
  43810. */
  43811. onDragStartObservable: Observable<{}>;
  43812. /**
  43813. * Fires each time a drag ends (eg. mouse release after drag)
  43814. */
  43815. onDragEndObservable: Observable<{}>;
  43816. /**
  43817. * 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
  43818. */
  43819. constructor();
  43820. /**
  43821. * The name of the behavior
  43822. */
  43823. get name(): string;
  43824. /**
  43825. * Initializes the behavior
  43826. */
  43827. init(): void;
  43828. /**
  43829. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  43830. */
  43831. private get _pointerCamera();
  43832. /**
  43833. * Attaches the scale behavior the passed in mesh
  43834. * @param ownerNode The mesh that will be scaled around once attached
  43835. */
  43836. attach(ownerNode: Mesh): void;
  43837. /**
  43838. * Detaches the behavior from the mesh
  43839. */
  43840. detach(): void;
  43841. }
  43842. }
  43843. declare module BABYLON {
  43844. /**
  43845. * Class used to apply inverse kinematics to bones
  43846. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  43847. */
  43848. export class BoneIKController {
  43849. private static _tmpVecs;
  43850. private static _tmpQuat;
  43851. private static _tmpMats;
  43852. /**
  43853. * Gets or sets the target mesh
  43854. */
  43855. targetMesh: AbstractMesh;
  43856. /** Gets or sets the mesh used as pole */
  43857. poleTargetMesh: AbstractMesh;
  43858. /**
  43859. * Gets or sets the bone used as pole
  43860. */
  43861. poleTargetBone: Nullable<Bone>;
  43862. /**
  43863. * Gets or sets the target position
  43864. */
  43865. targetPosition: Vector3;
  43866. /**
  43867. * Gets or sets the pole target position
  43868. */
  43869. poleTargetPosition: Vector3;
  43870. /**
  43871. * Gets or sets the pole target local offset
  43872. */
  43873. poleTargetLocalOffset: Vector3;
  43874. /**
  43875. * Gets or sets the pole angle
  43876. */
  43877. poleAngle: number;
  43878. /**
  43879. * Gets or sets the mesh associated with the controller
  43880. */
  43881. mesh: AbstractMesh;
  43882. /**
  43883. * 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)
  43884. */
  43885. slerpAmount: number;
  43886. private _bone1Quat;
  43887. private _bone1Mat;
  43888. private _bone2Ang;
  43889. private _bone1;
  43890. private _bone2;
  43891. private _bone1Length;
  43892. private _bone2Length;
  43893. private _maxAngle;
  43894. private _maxReach;
  43895. private _rightHandedSystem;
  43896. private _bendAxis;
  43897. private _slerping;
  43898. private _adjustRoll;
  43899. /**
  43900. * Gets or sets maximum allowed angle
  43901. */
  43902. get maxAngle(): number;
  43903. set maxAngle(value: number);
  43904. /**
  43905. * Creates a new BoneIKController
  43906. * @param mesh defines the mesh to control
  43907. * @param bone defines the bone to control
  43908. * @param options defines options to set up the controller
  43909. */
  43910. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  43911. targetMesh?: AbstractMesh;
  43912. poleTargetMesh?: AbstractMesh;
  43913. poleTargetBone?: Bone;
  43914. poleTargetLocalOffset?: Vector3;
  43915. poleAngle?: number;
  43916. bendAxis?: Vector3;
  43917. maxAngle?: number;
  43918. slerpAmount?: number;
  43919. });
  43920. private _setMaxAngle;
  43921. /**
  43922. * Force the controller to update the bones
  43923. */
  43924. update(): void;
  43925. }
  43926. }
  43927. declare module BABYLON {
  43928. /**
  43929. * Class used to make a bone look toward a point in space
  43930. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  43931. */
  43932. export class BoneLookController {
  43933. private static _tmpVecs;
  43934. private static _tmpQuat;
  43935. private static _tmpMats;
  43936. /**
  43937. * The target Vector3 that the bone will look at
  43938. */
  43939. target: Vector3;
  43940. /**
  43941. * The mesh that the bone is attached to
  43942. */
  43943. mesh: AbstractMesh;
  43944. /**
  43945. * The bone that will be looking to the target
  43946. */
  43947. bone: Bone;
  43948. /**
  43949. * The up axis of the coordinate system that is used when the bone is rotated
  43950. */
  43951. upAxis: Vector3;
  43952. /**
  43953. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  43954. */
  43955. upAxisSpace: Space;
  43956. /**
  43957. * Used to make an adjustment to the yaw of the bone
  43958. */
  43959. adjustYaw: number;
  43960. /**
  43961. * Used to make an adjustment to the pitch of the bone
  43962. */
  43963. adjustPitch: number;
  43964. /**
  43965. * Used to make an adjustment to the roll of the bone
  43966. */
  43967. adjustRoll: number;
  43968. /**
  43969. * 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)
  43970. */
  43971. slerpAmount: number;
  43972. private _minYaw;
  43973. private _maxYaw;
  43974. private _minPitch;
  43975. private _maxPitch;
  43976. private _minYawSin;
  43977. private _minYawCos;
  43978. private _maxYawSin;
  43979. private _maxYawCos;
  43980. private _midYawConstraint;
  43981. private _minPitchTan;
  43982. private _maxPitchTan;
  43983. private _boneQuat;
  43984. private _slerping;
  43985. private _transformYawPitch;
  43986. private _transformYawPitchInv;
  43987. private _firstFrameSkipped;
  43988. private _yawRange;
  43989. private _fowardAxis;
  43990. /**
  43991. * Gets or sets the minimum yaw angle that the bone can look to
  43992. */
  43993. get minYaw(): number;
  43994. set minYaw(value: number);
  43995. /**
  43996. * Gets or sets the maximum yaw angle that the bone can look to
  43997. */
  43998. get maxYaw(): number;
  43999. set maxYaw(value: number);
  44000. /**
  44001. * Gets or sets the minimum pitch angle that the bone can look to
  44002. */
  44003. get minPitch(): number;
  44004. set minPitch(value: number);
  44005. /**
  44006. * Gets or sets the maximum pitch angle that the bone can look to
  44007. */
  44008. get maxPitch(): number;
  44009. set maxPitch(value: number);
  44010. /**
  44011. * Create a BoneLookController
  44012. * @param mesh the mesh that the bone belongs to
  44013. * @param bone the bone that will be looking to the target
  44014. * @param target the target Vector3 to look at
  44015. * @param options optional settings:
  44016. * * maxYaw: the maximum angle the bone will yaw to
  44017. * * minYaw: the minimum angle the bone will yaw to
  44018. * * maxPitch: the maximum angle the bone will pitch to
  44019. * * minPitch: the minimum angle the bone will yaw to
  44020. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  44021. * * upAxis: the up axis of the coordinate system
  44022. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  44023. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  44024. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  44025. * * adjustYaw: used to make an adjustment to the yaw of the bone
  44026. * * adjustPitch: used to make an adjustment to the pitch of the bone
  44027. * * adjustRoll: used to make an adjustment to the roll of the bone
  44028. **/
  44029. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  44030. maxYaw?: number;
  44031. minYaw?: number;
  44032. maxPitch?: number;
  44033. minPitch?: number;
  44034. slerpAmount?: number;
  44035. upAxis?: Vector3;
  44036. upAxisSpace?: Space;
  44037. yawAxis?: Vector3;
  44038. pitchAxis?: Vector3;
  44039. adjustYaw?: number;
  44040. adjustPitch?: number;
  44041. adjustRoll?: number;
  44042. });
  44043. /**
  44044. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  44045. */
  44046. update(): void;
  44047. private _getAngleDiff;
  44048. private _getAngleBetween;
  44049. private _isAngleBetween;
  44050. }
  44051. }
  44052. declare module BABYLON {
  44053. /**
  44054. * Manage the gamepad inputs to control an arc rotate camera.
  44055. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44056. */
  44057. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  44058. /**
  44059. * Defines the camera the input is attached to.
  44060. */
  44061. camera: ArcRotateCamera;
  44062. /**
  44063. * Defines the gamepad the input is gathering event from.
  44064. */
  44065. gamepad: Nullable<Gamepad>;
  44066. /**
  44067. * Defines the gamepad rotation sensiblity.
  44068. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44069. */
  44070. gamepadRotationSensibility: number;
  44071. /**
  44072. * Defines the gamepad move sensiblity.
  44073. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44074. */
  44075. gamepadMoveSensibility: number;
  44076. private _yAxisScale;
  44077. /**
  44078. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44079. */
  44080. get invertYAxis(): boolean;
  44081. set invertYAxis(value: boolean);
  44082. private _onGamepadConnectedObserver;
  44083. private _onGamepadDisconnectedObserver;
  44084. /**
  44085. * Attach the input controls to a specific dom element to get the input from.
  44086. * @param element Defines the element the controls should be listened from
  44087. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44088. */
  44089. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44090. /**
  44091. * Detach the current controls from the specified dom element.
  44092. * @param element Defines the element to stop listening the inputs from
  44093. */
  44094. detachControl(element: Nullable<HTMLElement>): void;
  44095. /**
  44096. * Update the current camera state depending on the inputs that have been used this frame.
  44097. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44098. */
  44099. checkInputs(): void;
  44100. /**
  44101. * Gets the class name of the current intput.
  44102. * @returns the class name
  44103. */
  44104. getClassName(): string;
  44105. /**
  44106. * Get the friendly name associated with the input class.
  44107. * @returns the input friendly name
  44108. */
  44109. getSimpleName(): string;
  44110. }
  44111. }
  44112. declare module BABYLON {
  44113. interface ArcRotateCameraInputsManager {
  44114. /**
  44115. * Add orientation input support to the input manager.
  44116. * @returns the current input manager
  44117. */
  44118. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  44119. }
  44120. /**
  44121. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  44122. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44123. */
  44124. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  44125. /**
  44126. * Defines the camera the input is attached to.
  44127. */
  44128. camera: ArcRotateCamera;
  44129. /**
  44130. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  44131. */
  44132. alphaCorrection: number;
  44133. /**
  44134. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  44135. */
  44136. gammaCorrection: number;
  44137. private _alpha;
  44138. private _gamma;
  44139. private _dirty;
  44140. private _deviceOrientationHandler;
  44141. /**
  44142. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  44143. */
  44144. constructor();
  44145. /**
  44146. * Attach the input controls to a specific dom element to get the input from.
  44147. * @param element Defines the element the controls should be listened from
  44148. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44149. */
  44150. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44151. /** @hidden */
  44152. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  44153. /**
  44154. * Update the current camera state depending on the inputs that have been used this frame.
  44155. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44156. */
  44157. checkInputs(): void;
  44158. /**
  44159. * Detach the current controls from the specified dom element.
  44160. * @param element Defines the element to stop listening the inputs from
  44161. */
  44162. detachControl(element: Nullable<HTMLElement>): void;
  44163. /**
  44164. * Gets the class name of the current intput.
  44165. * @returns the class name
  44166. */
  44167. getClassName(): string;
  44168. /**
  44169. * Get the friendly name associated with the input class.
  44170. * @returns the input friendly name
  44171. */
  44172. getSimpleName(): string;
  44173. }
  44174. }
  44175. declare module BABYLON {
  44176. /**
  44177. * Listen to mouse events to control the camera.
  44178. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44179. */
  44180. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  44181. /**
  44182. * Defines the camera the input is attached to.
  44183. */
  44184. camera: FlyCamera;
  44185. /**
  44186. * Defines if touch is enabled. (Default is true.)
  44187. */
  44188. touchEnabled: boolean;
  44189. /**
  44190. * Defines the buttons associated with the input to handle camera rotation.
  44191. */
  44192. buttons: number[];
  44193. /**
  44194. * Assign buttons for Yaw control.
  44195. */
  44196. buttonsYaw: number[];
  44197. /**
  44198. * Assign buttons for Pitch control.
  44199. */
  44200. buttonsPitch: number[];
  44201. /**
  44202. * Assign buttons for Roll control.
  44203. */
  44204. buttonsRoll: number[];
  44205. /**
  44206. * Detect if any button is being pressed while mouse is moved.
  44207. * -1 = Mouse locked.
  44208. * 0 = Left button.
  44209. * 1 = Middle Button.
  44210. * 2 = Right Button.
  44211. */
  44212. activeButton: number;
  44213. /**
  44214. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  44215. * Higher values reduce its sensitivity.
  44216. */
  44217. angularSensibility: number;
  44218. private _mousemoveCallback;
  44219. private _observer;
  44220. private _rollObserver;
  44221. private previousPosition;
  44222. private noPreventDefault;
  44223. private element;
  44224. /**
  44225. * Listen to mouse events to control the camera.
  44226. * @param touchEnabled Define if touch is enabled. (Default is true.)
  44227. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44228. */
  44229. constructor(touchEnabled?: boolean);
  44230. /**
  44231. * Attach the mouse control to the HTML DOM element.
  44232. * @param element Defines the element that listens to the input events.
  44233. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  44234. */
  44235. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44236. /**
  44237. * Detach the current controls from the specified dom element.
  44238. * @param element Defines the element to stop listening the inputs from
  44239. */
  44240. detachControl(element: Nullable<HTMLElement>): void;
  44241. /**
  44242. * Gets the class name of the current input.
  44243. * @returns the class name.
  44244. */
  44245. getClassName(): string;
  44246. /**
  44247. * Get the friendly name associated with the input class.
  44248. * @returns the input's friendly name.
  44249. */
  44250. getSimpleName(): string;
  44251. private _pointerInput;
  44252. private _onMouseMove;
  44253. /**
  44254. * Rotate camera by mouse offset.
  44255. */
  44256. private rotateCamera;
  44257. }
  44258. }
  44259. declare module BABYLON {
  44260. /**
  44261. * Default Inputs manager for the FlyCamera.
  44262. * It groups all the default supported inputs for ease of use.
  44263. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44264. */
  44265. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  44266. /**
  44267. * Instantiates a new FlyCameraInputsManager.
  44268. * @param camera Defines the camera the inputs belong to.
  44269. */
  44270. constructor(camera: FlyCamera);
  44271. /**
  44272. * Add keyboard input support to the input manager.
  44273. * @returns the new FlyCameraKeyboardMoveInput().
  44274. */
  44275. addKeyboard(): FlyCameraInputsManager;
  44276. /**
  44277. * Add mouse input support to the input manager.
  44278. * @param touchEnabled Enable touch screen support.
  44279. * @returns the new FlyCameraMouseInput().
  44280. */
  44281. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  44282. }
  44283. }
  44284. declare module BABYLON {
  44285. /**
  44286. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44287. * such as in a 3D Space Shooter or a Flight Simulator.
  44288. */
  44289. export class FlyCamera extends TargetCamera {
  44290. /**
  44291. * Define the collision ellipsoid of the camera.
  44292. * This is helpful for simulating a camera body, like a player's body.
  44293. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44294. */
  44295. ellipsoid: Vector3;
  44296. /**
  44297. * Define an offset for the position of the ellipsoid around the camera.
  44298. * This can be helpful if the camera is attached away from the player's body center,
  44299. * such as at its head.
  44300. */
  44301. ellipsoidOffset: Vector3;
  44302. /**
  44303. * Enable or disable collisions of the camera with the rest of the scene objects.
  44304. */
  44305. checkCollisions: boolean;
  44306. /**
  44307. * Enable or disable gravity on the camera.
  44308. */
  44309. applyGravity: boolean;
  44310. /**
  44311. * Define the current direction the camera is moving to.
  44312. */
  44313. cameraDirection: Vector3;
  44314. /**
  44315. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  44316. * This overrides and empties cameraRotation.
  44317. */
  44318. rotationQuaternion: Quaternion;
  44319. /**
  44320. * Track Roll to maintain the wanted Rolling when looking around.
  44321. */
  44322. _trackRoll: number;
  44323. /**
  44324. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  44325. */
  44326. rollCorrect: number;
  44327. /**
  44328. * Mimic a banked turn, Rolling the camera when Yawing.
  44329. * It's recommended to use rollCorrect = 10 for faster banking correction.
  44330. */
  44331. bankedTurn: boolean;
  44332. /**
  44333. * Limit in radians for how much Roll banking will add. (Default: 90°)
  44334. */
  44335. bankedTurnLimit: number;
  44336. /**
  44337. * Value of 0 disables the banked Roll.
  44338. * Value of 1 is equal to the Yaw angle in radians.
  44339. */
  44340. bankedTurnMultiplier: number;
  44341. /**
  44342. * The inputs manager loads all the input sources, such as keyboard and mouse.
  44343. */
  44344. inputs: FlyCameraInputsManager;
  44345. /**
  44346. * Gets the input sensibility for mouse input.
  44347. * Higher values reduce sensitivity.
  44348. */
  44349. get angularSensibility(): number;
  44350. /**
  44351. * Sets the input sensibility for a mouse input.
  44352. * Higher values reduce sensitivity.
  44353. */
  44354. set angularSensibility(value: number);
  44355. /**
  44356. * Get the keys for camera movement forward.
  44357. */
  44358. get keysForward(): number[];
  44359. /**
  44360. * Set the keys for camera movement forward.
  44361. */
  44362. set keysForward(value: number[]);
  44363. /**
  44364. * Get the keys for camera movement backward.
  44365. */
  44366. get keysBackward(): number[];
  44367. set keysBackward(value: number[]);
  44368. /**
  44369. * Get the keys for camera movement up.
  44370. */
  44371. get keysUp(): number[];
  44372. /**
  44373. * Set the keys for camera movement up.
  44374. */
  44375. set keysUp(value: number[]);
  44376. /**
  44377. * Get the keys for camera movement down.
  44378. */
  44379. get keysDown(): number[];
  44380. /**
  44381. * Set the keys for camera movement down.
  44382. */
  44383. set keysDown(value: number[]);
  44384. /**
  44385. * Get the keys for camera movement left.
  44386. */
  44387. get keysLeft(): number[];
  44388. /**
  44389. * Set the keys for camera movement left.
  44390. */
  44391. set keysLeft(value: number[]);
  44392. /**
  44393. * Set the keys for camera movement right.
  44394. */
  44395. get keysRight(): number[];
  44396. /**
  44397. * Set the keys for camera movement right.
  44398. */
  44399. set keysRight(value: number[]);
  44400. /**
  44401. * Event raised when the camera collides with a mesh in the scene.
  44402. */
  44403. onCollide: (collidedMesh: AbstractMesh) => void;
  44404. private _collider;
  44405. private _needMoveForGravity;
  44406. private _oldPosition;
  44407. private _diffPosition;
  44408. private _newPosition;
  44409. /** @hidden */
  44410. _localDirection: Vector3;
  44411. /** @hidden */
  44412. _transformedDirection: Vector3;
  44413. /**
  44414. * Instantiates a FlyCamera.
  44415. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44416. * such as in a 3D Space Shooter or a Flight Simulator.
  44417. * @param name Define the name of the camera in the scene.
  44418. * @param position Define the starting position of the camera in the scene.
  44419. * @param scene Define the scene the camera belongs to.
  44420. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  44421. */
  44422. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44423. /**
  44424. * Attach a control to the HTML DOM element.
  44425. * @param element Defines the element that listens to the input events.
  44426. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  44427. */
  44428. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44429. /**
  44430. * Detach a control from the HTML DOM element.
  44431. * The camera will stop reacting to that input.
  44432. * @param element Defines the element that listens to the input events.
  44433. */
  44434. detachControl(element: HTMLElement): void;
  44435. private _collisionMask;
  44436. /**
  44437. * Get the mask that the camera ignores in collision events.
  44438. */
  44439. get collisionMask(): number;
  44440. /**
  44441. * Set the mask that the camera ignores in collision events.
  44442. */
  44443. set collisionMask(mask: number);
  44444. /** @hidden */
  44445. _collideWithWorld(displacement: Vector3): void;
  44446. /** @hidden */
  44447. private _onCollisionPositionChange;
  44448. /** @hidden */
  44449. _checkInputs(): void;
  44450. /** @hidden */
  44451. _decideIfNeedsToMove(): boolean;
  44452. /** @hidden */
  44453. _updatePosition(): void;
  44454. /**
  44455. * Restore the Roll to its target value at the rate specified.
  44456. * @param rate - Higher means slower restoring.
  44457. * @hidden
  44458. */
  44459. restoreRoll(rate: number): void;
  44460. /**
  44461. * Destroy the camera and release the current resources held by it.
  44462. */
  44463. dispose(): void;
  44464. /**
  44465. * Get the current object class name.
  44466. * @returns the class name.
  44467. */
  44468. getClassName(): string;
  44469. }
  44470. }
  44471. declare module BABYLON {
  44472. /**
  44473. * Listen to keyboard events to control the camera.
  44474. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44475. */
  44476. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  44477. /**
  44478. * Defines the camera the input is attached to.
  44479. */
  44480. camera: FlyCamera;
  44481. /**
  44482. * The list of keyboard keys used to control the forward move of the camera.
  44483. */
  44484. keysForward: number[];
  44485. /**
  44486. * The list of keyboard keys used to control the backward move of the camera.
  44487. */
  44488. keysBackward: number[];
  44489. /**
  44490. * The list of keyboard keys used to control the forward move of the camera.
  44491. */
  44492. keysUp: number[];
  44493. /**
  44494. * The list of keyboard keys used to control the backward move of the camera.
  44495. */
  44496. keysDown: number[];
  44497. /**
  44498. * The list of keyboard keys used to control the right strafe move of the camera.
  44499. */
  44500. keysRight: number[];
  44501. /**
  44502. * The list of keyboard keys used to control the left strafe move of the camera.
  44503. */
  44504. keysLeft: number[];
  44505. private _keys;
  44506. private _onCanvasBlurObserver;
  44507. private _onKeyboardObserver;
  44508. private _engine;
  44509. private _scene;
  44510. /**
  44511. * Attach the input controls to a specific dom element to get the input from.
  44512. * @param element Defines the element the controls should be listened from
  44513. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44514. */
  44515. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44516. /**
  44517. * Detach the current controls from the specified dom element.
  44518. * @param element Defines the element to stop listening the inputs from
  44519. */
  44520. detachControl(element: Nullable<HTMLElement>): void;
  44521. /**
  44522. * Gets the class name of the current intput.
  44523. * @returns the class name
  44524. */
  44525. getClassName(): string;
  44526. /** @hidden */
  44527. _onLostFocus(e: FocusEvent): void;
  44528. /**
  44529. * Get the friendly name associated with the input class.
  44530. * @returns the input friendly name
  44531. */
  44532. getSimpleName(): string;
  44533. /**
  44534. * Update the current camera state depending on the inputs that have been used this frame.
  44535. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44536. */
  44537. checkInputs(): void;
  44538. }
  44539. }
  44540. declare module BABYLON {
  44541. /**
  44542. * Manage the mouse wheel inputs to control a follow camera.
  44543. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44544. */
  44545. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  44546. /**
  44547. * Defines the camera the input is attached to.
  44548. */
  44549. camera: FollowCamera;
  44550. /**
  44551. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  44552. */
  44553. axisControlRadius: boolean;
  44554. /**
  44555. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  44556. */
  44557. axisControlHeight: boolean;
  44558. /**
  44559. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  44560. */
  44561. axisControlRotation: boolean;
  44562. /**
  44563. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  44564. * relation to mouseWheel events.
  44565. */
  44566. wheelPrecision: number;
  44567. /**
  44568. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44569. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44570. */
  44571. wheelDeltaPercentage: number;
  44572. private _wheel;
  44573. private _observer;
  44574. /**
  44575. * Attach the input controls to a specific dom element to get the input from.
  44576. * @param element Defines the element the controls should be listened from
  44577. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44578. */
  44579. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44580. /**
  44581. * Detach the current controls from the specified dom element.
  44582. * @param element Defines the element to stop listening the inputs from
  44583. */
  44584. detachControl(element: Nullable<HTMLElement>): void;
  44585. /**
  44586. * Gets the class name of the current intput.
  44587. * @returns the class name
  44588. */
  44589. getClassName(): string;
  44590. /**
  44591. * Get the friendly name associated with the input class.
  44592. * @returns the input friendly name
  44593. */
  44594. getSimpleName(): string;
  44595. }
  44596. }
  44597. declare module BABYLON {
  44598. /**
  44599. * Manage the pointers inputs to control an follow camera.
  44600. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44601. */
  44602. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  44603. /**
  44604. * Defines the camera the input is attached to.
  44605. */
  44606. camera: FollowCamera;
  44607. /**
  44608. * Gets the class name of the current input.
  44609. * @returns the class name
  44610. */
  44611. getClassName(): string;
  44612. /**
  44613. * Defines the pointer angular sensibility along the X axis or how fast is
  44614. * the camera rotating.
  44615. * A negative number will reverse the axis direction.
  44616. */
  44617. angularSensibilityX: number;
  44618. /**
  44619. * Defines the pointer angular sensibility along the Y axis or how fast is
  44620. * the camera rotating.
  44621. * A negative number will reverse the axis direction.
  44622. */
  44623. angularSensibilityY: number;
  44624. /**
  44625. * Defines the pointer pinch precision or how fast is the camera zooming.
  44626. * A negative number will reverse the axis direction.
  44627. */
  44628. pinchPrecision: number;
  44629. /**
  44630. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44631. * from 0.
  44632. * It defines the percentage of current camera.radius to use as delta when
  44633. * pinch zoom is used.
  44634. */
  44635. pinchDeltaPercentage: number;
  44636. /**
  44637. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  44638. */
  44639. axisXControlRadius: boolean;
  44640. /**
  44641. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  44642. */
  44643. axisXControlHeight: boolean;
  44644. /**
  44645. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  44646. */
  44647. axisXControlRotation: boolean;
  44648. /**
  44649. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  44650. */
  44651. axisYControlRadius: boolean;
  44652. /**
  44653. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  44654. */
  44655. axisYControlHeight: boolean;
  44656. /**
  44657. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  44658. */
  44659. axisYControlRotation: boolean;
  44660. /**
  44661. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  44662. */
  44663. axisPinchControlRadius: boolean;
  44664. /**
  44665. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  44666. */
  44667. axisPinchControlHeight: boolean;
  44668. /**
  44669. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  44670. */
  44671. axisPinchControlRotation: boolean;
  44672. /**
  44673. * Log error messages if basic misconfiguration has occurred.
  44674. */
  44675. warningEnable: boolean;
  44676. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44677. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44678. private _warningCounter;
  44679. private _warning;
  44680. }
  44681. }
  44682. declare module BABYLON {
  44683. /**
  44684. * Default Inputs manager for the FollowCamera.
  44685. * It groups all the default supported inputs for ease of use.
  44686. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44687. */
  44688. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  44689. /**
  44690. * Instantiates a new FollowCameraInputsManager.
  44691. * @param camera Defines the camera the inputs belong to
  44692. */
  44693. constructor(camera: FollowCamera);
  44694. /**
  44695. * Add keyboard input support to the input manager.
  44696. * @returns the current input manager
  44697. */
  44698. addKeyboard(): FollowCameraInputsManager;
  44699. /**
  44700. * Add mouse wheel input support to the input manager.
  44701. * @returns the current input manager
  44702. */
  44703. addMouseWheel(): FollowCameraInputsManager;
  44704. /**
  44705. * Add pointers input support to the input manager.
  44706. * @returns the current input manager
  44707. */
  44708. addPointers(): FollowCameraInputsManager;
  44709. /**
  44710. * Add orientation input support to the input manager.
  44711. * @returns the current input manager
  44712. */
  44713. addVRDeviceOrientation(): FollowCameraInputsManager;
  44714. }
  44715. }
  44716. declare module BABYLON {
  44717. /**
  44718. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  44719. * an arc rotate version arcFollowCamera are available.
  44720. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44721. */
  44722. export class FollowCamera extends TargetCamera {
  44723. /**
  44724. * Distance the follow camera should follow an object at
  44725. */
  44726. radius: number;
  44727. /**
  44728. * Minimum allowed distance of the camera to the axis of rotation
  44729. * (The camera can not get closer).
  44730. * This can help limiting how the Camera is able to move in the scene.
  44731. */
  44732. lowerRadiusLimit: Nullable<number>;
  44733. /**
  44734. * Maximum allowed distance of the camera to the axis of rotation
  44735. * (The camera can not get further).
  44736. * This can help limiting how the Camera is able to move in the scene.
  44737. */
  44738. upperRadiusLimit: Nullable<number>;
  44739. /**
  44740. * Define a rotation offset between the camera and the object it follows
  44741. */
  44742. rotationOffset: number;
  44743. /**
  44744. * Minimum allowed angle to camera position relative to target object.
  44745. * This can help limiting how the Camera is able to move in the scene.
  44746. */
  44747. lowerRotationOffsetLimit: Nullable<number>;
  44748. /**
  44749. * Maximum allowed angle to camera position relative to target object.
  44750. * This can help limiting how the Camera is able to move in the scene.
  44751. */
  44752. upperRotationOffsetLimit: Nullable<number>;
  44753. /**
  44754. * Define a height offset between the camera and the object it follows.
  44755. * It can help following an object from the top (like a car chaing a plane)
  44756. */
  44757. heightOffset: number;
  44758. /**
  44759. * Minimum allowed height of camera position relative to target object.
  44760. * This can help limiting how the Camera is able to move in the scene.
  44761. */
  44762. lowerHeightOffsetLimit: Nullable<number>;
  44763. /**
  44764. * Maximum allowed height of camera position relative to target object.
  44765. * This can help limiting how the Camera is able to move in the scene.
  44766. */
  44767. upperHeightOffsetLimit: Nullable<number>;
  44768. /**
  44769. * Define how fast the camera can accelerate to follow it s target.
  44770. */
  44771. cameraAcceleration: number;
  44772. /**
  44773. * Define the speed limit of the camera following an object.
  44774. */
  44775. maxCameraSpeed: number;
  44776. /**
  44777. * Define the target of the camera.
  44778. */
  44779. lockedTarget: Nullable<AbstractMesh>;
  44780. /**
  44781. * Defines the input associated with the camera.
  44782. */
  44783. inputs: FollowCameraInputsManager;
  44784. /**
  44785. * Instantiates the follow camera.
  44786. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44787. * @param name Define the name of the camera in the scene
  44788. * @param position Define the position of the camera
  44789. * @param scene Define the scene the camera belong to
  44790. * @param lockedTarget Define the target of the camera
  44791. */
  44792. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  44793. private _follow;
  44794. /**
  44795. * Attached controls to the current camera.
  44796. * @param element Defines the element the controls should be listened from
  44797. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44798. */
  44799. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44800. /**
  44801. * Detach the current controls from the camera.
  44802. * The camera will stop reacting to inputs.
  44803. * @param element Defines the element to stop listening the inputs from
  44804. */
  44805. detachControl(element: HTMLElement): void;
  44806. /** @hidden */
  44807. _checkInputs(): void;
  44808. private _checkLimits;
  44809. /**
  44810. * Gets the camera class name.
  44811. * @returns the class name
  44812. */
  44813. getClassName(): string;
  44814. }
  44815. /**
  44816. * Arc Rotate version of the follow camera.
  44817. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  44818. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44819. */
  44820. export class ArcFollowCamera extends TargetCamera {
  44821. /** The longitudinal angle of the camera */
  44822. alpha: number;
  44823. /** The latitudinal angle of the camera */
  44824. beta: number;
  44825. /** The radius of the camera from its target */
  44826. radius: number;
  44827. private _cartesianCoordinates;
  44828. /** Define the camera target (the mesh it should follow) */
  44829. private _meshTarget;
  44830. /**
  44831. * Instantiates a new ArcFollowCamera
  44832. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44833. * @param name Define the name of the camera
  44834. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  44835. * @param beta Define the rotation angle of the camera around the elevation axis
  44836. * @param radius Define the radius of the camera from its target point
  44837. * @param target Define the target of the camera
  44838. * @param scene Define the scene the camera belongs to
  44839. */
  44840. constructor(name: string,
  44841. /** The longitudinal angle of the camera */
  44842. alpha: number,
  44843. /** The latitudinal angle of the camera */
  44844. beta: number,
  44845. /** The radius of the camera from its target */
  44846. radius: number,
  44847. /** Define the camera target (the mesh it should follow) */
  44848. target: Nullable<AbstractMesh>, scene: Scene);
  44849. private _follow;
  44850. /** @hidden */
  44851. _checkInputs(): void;
  44852. /**
  44853. * Returns the class name of the object.
  44854. * It is mostly used internally for serialization purposes.
  44855. */
  44856. getClassName(): string;
  44857. }
  44858. }
  44859. declare module BABYLON {
  44860. /**
  44861. * Manage the keyboard inputs to control the movement of a follow camera.
  44862. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44863. */
  44864. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  44865. /**
  44866. * Defines the camera the input is attached to.
  44867. */
  44868. camera: FollowCamera;
  44869. /**
  44870. * Defines the list of key codes associated with the up action (increase heightOffset)
  44871. */
  44872. keysHeightOffsetIncr: number[];
  44873. /**
  44874. * Defines the list of key codes associated with the down action (decrease heightOffset)
  44875. */
  44876. keysHeightOffsetDecr: number[];
  44877. /**
  44878. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  44879. */
  44880. keysHeightOffsetModifierAlt: boolean;
  44881. /**
  44882. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  44883. */
  44884. keysHeightOffsetModifierCtrl: boolean;
  44885. /**
  44886. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  44887. */
  44888. keysHeightOffsetModifierShift: boolean;
  44889. /**
  44890. * Defines the list of key codes associated with the left action (increase rotationOffset)
  44891. */
  44892. keysRotationOffsetIncr: number[];
  44893. /**
  44894. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  44895. */
  44896. keysRotationOffsetDecr: number[];
  44897. /**
  44898. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  44899. */
  44900. keysRotationOffsetModifierAlt: boolean;
  44901. /**
  44902. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  44903. */
  44904. keysRotationOffsetModifierCtrl: boolean;
  44905. /**
  44906. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  44907. */
  44908. keysRotationOffsetModifierShift: boolean;
  44909. /**
  44910. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  44911. */
  44912. keysRadiusIncr: number[];
  44913. /**
  44914. * Defines the list of key codes associated with the zoom-out action (increase radius)
  44915. */
  44916. keysRadiusDecr: number[];
  44917. /**
  44918. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  44919. */
  44920. keysRadiusModifierAlt: boolean;
  44921. /**
  44922. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  44923. */
  44924. keysRadiusModifierCtrl: boolean;
  44925. /**
  44926. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  44927. */
  44928. keysRadiusModifierShift: boolean;
  44929. /**
  44930. * Defines the rate of change of heightOffset.
  44931. */
  44932. heightSensibility: number;
  44933. /**
  44934. * Defines the rate of change of rotationOffset.
  44935. */
  44936. rotationSensibility: number;
  44937. /**
  44938. * Defines the rate of change of radius.
  44939. */
  44940. radiusSensibility: number;
  44941. private _keys;
  44942. private _ctrlPressed;
  44943. private _altPressed;
  44944. private _shiftPressed;
  44945. private _onCanvasBlurObserver;
  44946. private _onKeyboardObserver;
  44947. private _engine;
  44948. private _scene;
  44949. /**
  44950. * Attach the input controls to a specific dom element to get the input from.
  44951. * @param element Defines the element the controls should be listened from
  44952. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44953. */
  44954. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44955. /**
  44956. * Detach the current controls from the specified dom element.
  44957. * @param element Defines the element to stop listening the inputs from
  44958. */
  44959. detachControl(element: Nullable<HTMLElement>): void;
  44960. /**
  44961. * Update the current camera state depending on the inputs that have been used this frame.
  44962. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44963. */
  44964. checkInputs(): void;
  44965. /**
  44966. * Gets the class name of the current input.
  44967. * @returns the class name
  44968. */
  44969. getClassName(): string;
  44970. /**
  44971. * Get the friendly name associated with the input class.
  44972. * @returns the input friendly name
  44973. */
  44974. getSimpleName(): string;
  44975. /**
  44976. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44977. * allow modification of the heightOffset value.
  44978. */
  44979. private _modifierHeightOffset;
  44980. /**
  44981. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44982. * allow modification of the rotationOffset value.
  44983. */
  44984. private _modifierRotationOffset;
  44985. /**
  44986. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44987. * allow modification of the radius value.
  44988. */
  44989. private _modifierRadius;
  44990. }
  44991. }
  44992. declare module BABYLON {
  44993. interface FreeCameraInputsManager {
  44994. /**
  44995. * @hidden
  44996. */
  44997. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  44998. /**
  44999. * Add orientation input support to the input manager.
  45000. * @returns the current input manager
  45001. */
  45002. addDeviceOrientation(): FreeCameraInputsManager;
  45003. }
  45004. /**
  45005. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  45006. * Screen rotation is taken into account.
  45007. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45008. */
  45009. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  45010. private _camera;
  45011. private _screenOrientationAngle;
  45012. private _constantTranform;
  45013. private _screenQuaternion;
  45014. private _alpha;
  45015. private _beta;
  45016. private _gamma;
  45017. /**
  45018. * Can be used to detect if a device orientation sensor is available on a device
  45019. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  45020. * @returns a promise that will resolve on orientation change
  45021. */
  45022. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  45023. /**
  45024. * @hidden
  45025. */
  45026. _onDeviceOrientationChangedObservable: Observable<void>;
  45027. /**
  45028. * Instantiates a new input
  45029. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45030. */
  45031. constructor();
  45032. /**
  45033. * Define the camera controlled by the input.
  45034. */
  45035. get camera(): FreeCamera;
  45036. set camera(camera: FreeCamera);
  45037. /**
  45038. * Attach the input controls to a specific dom element to get the input from.
  45039. * @param element Defines the element the controls should be listened from
  45040. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45041. */
  45042. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45043. private _orientationChanged;
  45044. private _deviceOrientation;
  45045. /**
  45046. * Detach the current controls from the specified dom element.
  45047. * @param element Defines the element to stop listening the inputs from
  45048. */
  45049. detachControl(element: Nullable<HTMLElement>): void;
  45050. /**
  45051. * Update the current camera state depending on the inputs that have been used this frame.
  45052. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45053. */
  45054. checkInputs(): void;
  45055. /**
  45056. * Gets the class name of the current intput.
  45057. * @returns the class name
  45058. */
  45059. getClassName(): string;
  45060. /**
  45061. * Get the friendly name associated with the input class.
  45062. * @returns the input friendly name
  45063. */
  45064. getSimpleName(): string;
  45065. }
  45066. }
  45067. declare module BABYLON {
  45068. /**
  45069. * Manage the gamepad inputs to control a free camera.
  45070. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45071. */
  45072. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  45073. /**
  45074. * Define the camera the input is attached to.
  45075. */
  45076. camera: FreeCamera;
  45077. /**
  45078. * Define the Gamepad controlling the input
  45079. */
  45080. gamepad: Nullable<Gamepad>;
  45081. /**
  45082. * Defines the gamepad rotation sensiblity.
  45083. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45084. */
  45085. gamepadAngularSensibility: number;
  45086. /**
  45087. * Defines the gamepad move sensiblity.
  45088. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45089. */
  45090. gamepadMoveSensibility: number;
  45091. private _yAxisScale;
  45092. /**
  45093. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45094. */
  45095. get invertYAxis(): boolean;
  45096. set invertYAxis(value: boolean);
  45097. private _onGamepadConnectedObserver;
  45098. private _onGamepadDisconnectedObserver;
  45099. private _cameraTransform;
  45100. private _deltaTransform;
  45101. private _vector3;
  45102. private _vector2;
  45103. /**
  45104. * Attach the input controls to a specific dom element to get the input from.
  45105. * @param element Defines the element the controls should be listened from
  45106. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45107. */
  45108. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45109. /**
  45110. * Detach the current controls from the specified dom element.
  45111. * @param element Defines the element to stop listening the inputs from
  45112. */
  45113. detachControl(element: Nullable<HTMLElement>): void;
  45114. /**
  45115. * Update the current camera state depending on the inputs that have been used this frame.
  45116. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45117. */
  45118. checkInputs(): void;
  45119. /**
  45120. * Gets the class name of the current intput.
  45121. * @returns the class name
  45122. */
  45123. getClassName(): string;
  45124. /**
  45125. * Get the friendly name associated with the input class.
  45126. * @returns the input friendly name
  45127. */
  45128. getSimpleName(): string;
  45129. }
  45130. }
  45131. declare module BABYLON {
  45132. /**
  45133. * Defines the potential axis of a Joystick
  45134. */
  45135. export enum JoystickAxis {
  45136. /** X axis */
  45137. X = 0,
  45138. /** Y axis */
  45139. Y = 1,
  45140. /** Z axis */
  45141. Z = 2
  45142. }
  45143. /**
  45144. * Represents the different customization options available
  45145. * for VirtualJoystick
  45146. */
  45147. interface VirtualJoystickCustomizations {
  45148. /**
  45149. * Size of the joystick's puck
  45150. */
  45151. puckSize: number;
  45152. /**
  45153. * Size of the joystick's container
  45154. */
  45155. containerSize: number;
  45156. /**
  45157. * Color of the joystick && puck
  45158. */
  45159. color: string;
  45160. /**
  45161. * Image URL for the joystick's puck
  45162. */
  45163. puckImage?: string;
  45164. /**
  45165. * Image URL for the joystick's container
  45166. */
  45167. containerImage?: string;
  45168. /**
  45169. * Defines the unmoving position of the joystick container
  45170. */
  45171. position?: {
  45172. x: number;
  45173. y: number;
  45174. };
  45175. /**
  45176. * Defines whether or not the joystick container is always visible
  45177. */
  45178. alwaysVisible: boolean;
  45179. /**
  45180. * Defines whether or not to limit the movement of the puck to the joystick's container
  45181. */
  45182. limitToContainer: boolean;
  45183. }
  45184. /**
  45185. * Class used to define virtual joystick (used in touch mode)
  45186. */
  45187. export class VirtualJoystick {
  45188. /**
  45189. * Gets or sets a boolean indicating that left and right values must be inverted
  45190. */
  45191. reverseLeftRight: boolean;
  45192. /**
  45193. * Gets or sets a boolean indicating that up and down values must be inverted
  45194. */
  45195. reverseUpDown: boolean;
  45196. /**
  45197. * Gets the offset value for the position (ie. the change of the position value)
  45198. */
  45199. deltaPosition: Vector3;
  45200. /**
  45201. * Gets a boolean indicating if the virtual joystick was pressed
  45202. */
  45203. pressed: boolean;
  45204. /**
  45205. * Canvas the virtual joystick will render onto, default z-index of this is 5
  45206. */
  45207. static Canvas: Nullable<HTMLCanvasElement>;
  45208. /**
  45209. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  45210. */
  45211. limitToContainer: boolean;
  45212. private static _globalJoystickIndex;
  45213. private static _alwaysVisibleSticks;
  45214. private static vjCanvasContext;
  45215. private static vjCanvasWidth;
  45216. private static vjCanvasHeight;
  45217. private static halfWidth;
  45218. private static _GetDefaultOptions;
  45219. private _action;
  45220. private _axisTargetedByLeftAndRight;
  45221. private _axisTargetedByUpAndDown;
  45222. private _joystickSensibility;
  45223. private _inversedSensibility;
  45224. private _joystickPointerID;
  45225. private _joystickColor;
  45226. private _joystickPointerPos;
  45227. private _joystickPreviousPointerPos;
  45228. private _joystickPointerStartPos;
  45229. private _deltaJoystickVector;
  45230. private _leftJoystick;
  45231. private _touches;
  45232. private _joystickPosition;
  45233. private _alwaysVisible;
  45234. private _puckImage;
  45235. private _containerImage;
  45236. private _joystickPuckSize;
  45237. private _joystickContainerSize;
  45238. private _clearPuckSize;
  45239. private _clearContainerSize;
  45240. private _clearPuckSizeOffset;
  45241. private _clearContainerSizeOffset;
  45242. private _onPointerDownHandlerRef;
  45243. private _onPointerMoveHandlerRef;
  45244. private _onPointerUpHandlerRef;
  45245. private _onResize;
  45246. /**
  45247. * Creates a new virtual joystick
  45248. * @param leftJoystick defines that the joystick is for left hand (false by default)
  45249. * @param customizations Defines the options we want to customize the VirtualJoystick
  45250. */
  45251. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  45252. /**
  45253. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  45254. * @param newJoystickSensibility defines the new sensibility
  45255. */
  45256. setJoystickSensibility(newJoystickSensibility: number): void;
  45257. private _onPointerDown;
  45258. private _onPointerMove;
  45259. private _onPointerUp;
  45260. /**
  45261. * Change the color of the virtual joystick
  45262. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  45263. */
  45264. setJoystickColor(newColor: string): void;
  45265. /**
  45266. * Size of the joystick's container
  45267. */
  45268. set containerSize(newSize: number);
  45269. get containerSize(): number;
  45270. /**
  45271. * Size of the joystick's puck
  45272. */
  45273. set puckSize(newSize: number);
  45274. get puckSize(): number;
  45275. /**
  45276. * Clears the set position of the joystick
  45277. */
  45278. clearPosition(): void;
  45279. /**
  45280. * Defines whether or not the joystick container is always visible
  45281. */
  45282. set alwaysVisible(value: boolean);
  45283. get alwaysVisible(): boolean;
  45284. /**
  45285. * Sets the constant position of the Joystick container
  45286. * @param x X axis coordinate
  45287. * @param y Y axis coordinate
  45288. */
  45289. setPosition(x: number, y: number): void;
  45290. /**
  45291. * Defines a callback to call when the joystick is touched
  45292. * @param action defines the callback
  45293. */
  45294. setActionOnTouch(action: () => any): void;
  45295. /**
  45296. * Defines which axis you'd like to control for left & right
  45297. * @param axis defines the axis to use
  45298. */
  45299. setAxisForLeftRight(axis: JoystickAxis): void;
  45300. /**
  45301. * Defines which axis you'd like to control for up & down
  45302. * @param axis defines the axis to use
  45303. */
  45304. setAxisForUpDown(axis: JoystickAxis): void;
  45305. /**
  45306. * Clears the canvas from the previous puck / container draw
  45307. */
  45308. private _clearPreviousDraw;
  45309. /**
  45310. * Loads `urlPath` to be used for the container's image
  45311. * @param urlPath defines the urlPath of an image to use
  45312. */
  45313. setContainerImage(urlPath: string): void;
  45314. /**
  45315. * Loads `urlPath` to be used for the puck's image
  45316. * @param urlPath defines the urlPath of an image to use
  45317. */
  45318. setPuckImage(urlPath: string): void;
  45319. /**
  45320. * Draws the Virtual Joystick's container
  45321. */
  45322. private _drawContainer;
  45323. /**
  45324. * Draws the Virtual Joystick's puck
  45325. */
  45326. private _drawPuck;
  45327. private _drawVirtualJoystick;
  45328. /**
  45329. * Release internal HTML canvas
  45330. */
  45331. releaseCanvas(): void;
  45332. }
  45333. }
  45334. declare module BABYLON {
  45335. interface FreeCameraInputsManager {
  45336. /**
  45337. * Add virtual joystick input support to the input manager.
  45338. * @returns the current input manager
  45339. */
  45340. addVirtualJoystick(): FreeCameraInputsManager;
  45341. }
  45342. /**
  45343. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  45344. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45345. */
  45346. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  45347. /**
  45348. * Defines the camera the input is attached to.
  45349. */
  45350. camera: FreeCamera;
  45351. private _leftjoystick;
  45352. private _rightjoystick;
  45353. /**
  45354. * Gets the left stick of the virtual joystick.
  45355. * @returns The virtual Joystick
  45356. */
  45357. getLeftJoystick(): VirtualJoystick;
  45358. /**
  45359. * Gets the right stick of the virtual joystick.
  45360. * @returns The virtual Joystick
  45361. */
  45362. getRightJoystick(): VirtualJoystick;
  45363. /**
  45364. * Update the current camera state depending on the inputs that have been used this frame.
  45365. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45366. */
  45367. checkInputs(): void;
  45368. /**
  45369. * Attach the input controls to a specific dom element to get the input from.
  45370. * @param element Defines the element the controls should be listened from
  45371. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45372. */
  45373. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45374. /**
  45375. * Detach the current controls from the specified dom element.
  45376. * @param element Defines the element to stop listening the inputs from
  45377. */
  45378. detachControl(element: Nullable<HTMLElement>): void;
  45379. /**
  45380. * Gets the class name of the current intput.
  45381. * @returns the class name
  45382. */
  45383. getClassName(): string;
  45384. /**
  45385. * Get the friendly name associated with the input class.
  45386. * @returns the input friendly name
  45387. */
  45388. getSimpleName(): string;
  45389. }
  45390. }
  45391. declare module BABYLON {
  45392. /**
  45393. * This represents a FPS type of camera controlled by touch.
  45394. * This is like a universal camera minus the Gamepad controls.
  45395. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45396. */
  45397. export class TouchCamera extends FreeCamera {
  45398. /**
  45399. * Defines the touch sensibility for rotation.
  45400. * The higher the faster.
  45401. */
  45402. get touchAngularSensibility(): number;
  45403. set touchAngularSensibility(value: number);
  45404. /**
  45405. * Defines the touch sensibility for move.
  45406. * The higher the faster.
  45407. */
  45408. get touchMoveSensibility(): number;
  45409. set touchMoveSensibility(value: number);
  45410. /**
  45411. * Instantiates a new touch camera.
  45412. * This represents a FPS type of camera controlled by touch.
  45413. * This is like a universal camera minus the Gamepad controls.
  45414. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45415. * @param name Define the name of the camera in the scene
  45416. * @param position Define the start position of the camera in the scene
  45417. * @param scene Define the scene the camera belongs to
  45418. */
  45419. constructor(name: string, position: Vector3, scene: Scene);
  45420. /**
  45421. * Gets the current object class name.
  45422. * @return the class name
  45423. */
  45424. getClassName(): string;
  45425. /** @hidden */
  45426. _setupInputs(): void;
  45427. }
  45428. }
  45429. declare module BABYLON {
  45430. /**
  45431. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  45432. * being tilted forward or back and left or right.
  45433. */
  45434. export class DeviceOrientationCamera extends FreeCamera {
  45435. private _initialQuaternion;
  45436. private _quaternionCache;
  45437. private _tmpDragQuaternion;
  45438. private _disablePointerInputWhenUsingDeviceOrientation;
  45439. /**
  45440. * Creates a new device orientation camera
  45441. * @param name The name of the camera
  45442. * @param position The start position camera
  45443. * @param scene The scene the camera belongs to
  45444. */
  45445. constructor(name: string, position: Vector3, scene: Scene);
  45446. /**
  45447. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  45448. */
  45449. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  45450. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  45451. private _dragFactor;
  45452. /**
  45453. * Enabled turning on the y axis when the orientation sensor is active
  45454. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  45455. */
  45456. enableHorizontalDragging(dragFactor?: number): void;
  45457. /**
  45458. * Gets the current instance class name ("DeviceOrientationCamera").
  45459. * This helps avoiding instanceof at run time.
  45460. * @returns the class name
  45461. */
  45462. getClassName(): string;
  45463. /**
  45464. * @hidden
  45465. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  45466. */
  45467. _checkInputs(): void;
  45468. /**
  45469. * Reset the camera to its default orientation on the specified axis only.
  45470. * @param axis The axis to reset
  45471. */
  45472. resetToCurrentRotation(axis?: Axis): void;
  45473. }
  45474. }
  45475. declare module BABYLON {
  45476. /**
  45477. * Defines supported buttons for XBox360 compatible gamepads
  45478. */
  45479. export enum Xbox360Button {
  45480. /** A */
  45481. A = 0,
  45482. /** B */
  45483. B = 1,
  45484. /** X */
  45485. X = 2,
  45486. /** Y */
  45487. Y = 3,
  45488. /** Left button */
  45489. LB = 4,
  45490. /** Right button */
  45491. RB = 5,
  45492. /** Back */
  45493. Back = 8,
  45494. /** Start */
  45495. Start = 9,
  45496. /** Left stick */
  45497. LeftStick = 10,
  45498. /** Right stick */
  45499. RightStick = 11
  45500. }
  45501. /** Defines values for XBox360 DPad */
  45502. export enum Xbox360Dpad {
  45503. /** Up */
  45504. Up = 12,
  45505. /** Down */
  45506. Down = 13,
  45507. /** Left */
  45508. Left = 14,
  45509. /** Right */
  45510. Right = 15
  45511. }
  45512. /**
  45513. * Defines a XBox360 gamepad
  45514. */
  45515. export class Xbox360Pad extends Gamepad {
  45516. private _leftTrigger;
  45517. private _rightTrigger;
  45518. private _onlefttriggerchanged;
  45519. private _onrighttriggerchanged;
  45520. private _onbuttondown;
  45521. private _onbuttonup;
  45522. private _ondpaddown;
  45523. private _ondpadup;
  45524. /** Observable raised when a button is pressed */
  45525. onButtonDownObservable: Observable<Xbox360Button>;
  45526. /** Observable raised when a button is released */
  45527. onButtonUpObservable: Observable<Xbox360Button>;
  45528. /** Observable raised when a pad is pressed */
  45529. onPadDownObservable: Observable<Xbox360Dpad>;
  45530. /** Observable raised when a pad is released */
  45531. onPadUpObservable: Observable<Xbox360Dpad>;
  45532. private _buttonA;
  45533. private _buttonB;
  45534. private _buttonX;
  45535. private _buttonY;
  45536. private _buttonBack;
  45537. private _buttonStart;
  45538. private _buttonLB;
  45539. private _buttonRB;
  45540. private _buttonLeftStick;
  45541. private _buttonRightStick;
  45542. private _dPadUp;
  45543. private _dPadDown;
  45544. private _dPadLeft;
  45545. private _dPadRight;
  45546. private _isXboxOnePad;
  45547. /**
  45548. * Creates a new XBox360 gamepad object
  45549. * @param id defines the id of this gamepad
  45550. * @param index defines its index
  45551. * @param gamepad defines the internal HTML gamepad object
  45552. * @param xboxOne defines if it is a XBox One gamepad
  45553. */
  45554. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  45555. /**
  45556. * Defines the callback to call when left trigger is pressed
  45557. * @param callback defines the callback to use
  45558. */
  45559. onlefttriggerchanged(callback: (value: number) => void): void;
  45560. /**
  45561. * Defines the callback to call when right trigger is pressed
  45562. * @param callback defines the callback to use
  45563. */
  45564. onrighttriggerchanged(callback: (value: number) => void): void;
  45565. /**
  45566. * Gets the left trigger value
  45567. */
  45568. get leftTrigger(): number;
  45569. /**
  45570. * Sets the left trigger value
  45571. */
  45572. set leftTrigger(newValue: number);
  45573. /**
  45574. * Gets the right trigger value
  45575. */
  45576. get rightTrigger(): number;
  45577. /**
  45578. * Sets the right trigger value
  45579. */
  45580. set rightTrigger(newValue: number);
  45581. /**
  45582. * Defines the callback to call when a button is pressed
  45583. * @param callback defines the callback to use
  45584. */
  45585. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  45586. /**
  45587. * Defines the callback to call when a button is released
  45588. * @param callback defines the callback to use
  45589. */
  45590. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  45591. /**
  45592. * Defines the callback to call when a pad is pressed
  45593. * @param callback defines the callback to use
  45594. */
  45595. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  45596. /**
  45597. * Defines the callback to call when a pad is released
  45598. * @param callback defines the callback to use
  45599. */
  45600. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  45601. private _setButtonValue;
  45602. private _setDPadValue;
  45603. /**
  45604. * Gets the value of the `A` button
  45605. */
  45606. get buttonA(): number;
  45607. /**
  45608. * Sets the value of the `A` button
  45609. */
  45610. set buttonA(value: number);
  45611. /**
  45612. * Gets the value of the `B` button
  45613. */
  45614. get buttonB(): number;
  45615. /**
  45616. * Sets the value of the `B` button
  45617. */
  45618. set buttonB(value: number);
  45619. /**
  45620. * Gets the value of the `X` button
  45621. */
  45622. get buttonX(): number;
  45623. /**
  45624. * Sets the value of the `X` button
  45625. */
  45626. set buttonX(value: number);
  45627. /**
  45628. * Gets the value of the `Y` button
  45629. */
  45630. get buttonY(): number;
  45631. /**
  45632. * Sets the value of the `Y` button
  45633. */
  45634. set buttonY(value: number);
  45635. /**
  45636. * Gets the value of the `Start` button
  45637. */
  45638. get buttonStart(): number;
  45639. /**
  45640. * Sets the value of the `Start` button
  45641. */
  45642. set buttonStart(value: number);
  45643. /**
  45644. * Gets the value of the `Back` button
  45645. */
  45646. get buttonBack(): number;
  45647. /**
  45648. * Sets the value of the `Back` button
  45649. */
  45650. set buttonBack(value: number);
  45651. /**
  45652. * Gets the value of the `Left` button
  45653. */
  45654. get buttonLB(): number;
  45655. /**
  45656. * Sets the value of the `Left` button
  45657. */
  45658. set buttonLB(value: number);
  45659. /**
  45660. * Gets the value of the `Right` button
  45661. */
  45662. get buttonRB(): number;
  45663. /**
  45664. * Sets the value of the `Right` button
  45665. */
  45666. set buttonRB(value: number);
  45667. /**
  45668. * Gets the value of the Left joystick
  45669. */
  45670. get buttonLeftStick(): number;
  45671. /**
  45672. * Sets the value of the Left joystick
  45673. */
  45674. set buttonLeftStick(value: number);
  45675. /**
  45676. * Gets the value of the Right joystick
  45677. */
  45678. get buttonRightStick(): number;
  45679. /**
  45680. * Sets the value of the Right joystick
  45681. */
  45682. set buttonRightStick(value: number);
  45683. /**
  45684. * Gets the value of D-pad up
  45685. */
  45686. get dPadUp(): number;
  45687. /**
  45688. * Sets the value of D-pad up
  45689. */
  45690. set dPadUp(value: number);
  45691. /**
  45692. * Gets the value of D-pad down
  45693. */
  45694. get dPadDown(): number;
  45695. /**
  45696. * Sets the value of D-pad down
  45697. */
  45698. set dPadDown(value: number);
  45699. /**
  45700. * Gets the value of D-pad left
  45701. */
  45702. get dPadLeft(): number;
  45703. /**
  45704. * Sets the value of D-pad left
  45705. */
  45706. set dPadLeft(value: number);
  45707. /**
  45708. * Gets the value of D-pad right
  45709. */
  45710. get dPadRight(): number;
  45711. /**
  45712. * Sets the value of D-pad right
  45713. */
  45714. set dPadRight(value: number);
  45715. /**
  45716. * Force the gamepad to synchronize with device values
  45717. */
  45718. update(): void;
  45719. /**
  45720. * Disposes the gamepad
  45721. */
  45722. dispose(): void;
  45723. }
  45724. }
  45725. declare module BABYLON {
  45726. /**
  45727. * Defines supported buttons for DualShock compatible gamepads
  45728. */
  45729. export enum DualShockButton {
  45730. /** Cross */
  45731. Cross = 0,
  45732. /** Circle */
  45733. Circle = 1,
  45734. /** Square */
  45735. Square = 2,
  45736. /** Triangle */
  45737. Triangle = 3,
  45738. /** L1 */
  45739. L1 = 4,
  45740. /** R1 */
  45741. R1 = 5,
  45742. /** Share */
  45743. Share = 8,
  45744. /** Options */
  45745. Options = 9,
  45746. /** Left stick */
  45747. LeftStick = 10,
  45748. /** Right stick */
  45749. RightStick = 11
  45750. }
  45751. /** Defines values for DualShock DPad */
  45752. export enum DualShockDpad {
  45753. /** Up */
  45754. Up = 12,
  45755. /** Down */
  45756. Down = 13,
  45757. /** Left */
  45758. Left = 14,
  45759. /** Right */
  45760. Right = 15
  45761. }
  45762. /**
  45763. * Defines a DualShock gamepad
  45764. */
  45765. export class DualShockPad extends Gamepad {
  45766. private _leftTrigger;
  45767. private _rightTrigger;
  45768. private _onlefttriggerchanged;
  45769. private _onrighttriggerchanged;
  45770. private _onbuttondown;
  45771. private _onbuttonup;
  45772. private _ondpaddown;
  45773. private _ondpadup;
  45774. /** Observable raised when a button is pressed */
  45775. onButtonDownObservable: Observable<DualShockButton>;
  45776. /** Observable raised when a button is released */
  45777. onButtonUpObservable: Observable<DualShockButton>;
  45778. /** Observable raised when a pad is pressed */
  45779. onPadDownObservable: Observable<DualShockDpad>;
  45780. /** Observable raised when a pad is released */
  45781. onPadUpObservable: Observable<DualShockDpad>;
  45782. private _buttonCross;
  45783. private _buttonCircle;
  45784. private _buttonSquare;
  45785. private _buttonTriangle;
  45786. private _buttonShare;
  45787. private _buttonOptions;
  45788. private _buttonL1;
  45789. private _buttonR1;
  45790. private _buttonLeftStick;
  45791. private _buttonRightStick;
  45792. private _dPadUp;
  45793. private _dPadDown;
  45794. private _dPadLeft;
  45795. private _dPadRight;
  45796. /**
  45797. * Creates a new DualShock gamepad object
  45798. * @param id defines the id of this gamepad
  45799. * @param index defines its index
  45800. * @param gamepad defines the internal HTML gamepad object
  45801. */
  45802. constructor(id: string, index: number, gamepad: any);
  45803. /**
  45804. * Defines the callback to call when left trigger is pressed
  45805. * @param callback defines the callback to use
  45806. */
  45807. onlefttriggerchanged(callback: (value: number) => void): void;
  45808. /**
  45809. * Defines the callback to call when right trigger is pressed
  45810. * @param callback defines the callback to use
  45811. */
  45812. onrighttriggerchanged(callback: (value: number) => void): void;
  45813. /**
  45814. * Gets the left trigger value
  45815. */
  45816. get leftTrigger(): number;
  45817. /**
  45818. * Sets the left trigger value
  45819. */
  45820. set leftTrigger(newValue: number);
  45821. /**
  45822. * Gets the right trigger value
  45823. */
  45824. get rightTrigger(): number;
  45825. /**
  45826. * Sets the right trigger value
  45827. */
  45828. set rightTrigger(newValue: number);
  45829. /**
  45830. * Defines the callback to call when a button is pressed
  45831. * @param callback defines the callback to use
  45832. */
  45833. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  45834. /**
  45835. * Defines the callback to call when a button is released
  45836. * @param callback defines the callback to use
  45837. */
  45838. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  45839. /**
  45840. * Defines the callback to call when a pad is pressed
  45841. * @param callback defines the callback to use
  45842. */
  45843. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  45844. /**
  45845. * Defines the callback to call when a pad is released
  45846. * @param callback defines the callback to use
  45847. */
  45848. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  45849. private _setButtonValue;
  45850. private _setDPadValue;
  45851. /**
  45852. * Gets the value of the `Cross` button
  45853. */
  45854. get buttonCross(): number;
  45855. /**
  45856. * Sets the value of the `Cross` button
  45857. */
  45858. set buttonCross(value: number);
  45859. /**
  45860. * Gets the value of the `Circle` button
  45861. */
  45862. get buttonCircle(): number;
  45863. /**
  45864. * Sets the value of the `Circle` button
  45865. */
  45866. set buttonCircle(value: number);
  45867. /**
  45868. * Gets the value of the `Square` button
  45869. */
  45870. get buttonSquare(): number;
  45871. /**
  45872. * Sets the value of the `Square` button
  45873. */
  45874. set buttonSquare(value: number);
  45875. /**
  45876. * Gets the value of the `Triangle` button
  45877. */
  45878. get buttonTriangle(): number;
  45879. /**
  45880. * Sets the value of the `Triangle` button
  45881. */
  45882. set buttonTriangle(value: number);
  45883. /**
  45884. * Gets the value of the `Options` button
  45885. */
  45886. get buttonOptions(): number;
  45887. /**
  45888. * Sets the value of the `Options` button
  45889. */
  45890. set buttonOptions(value: number);
  45891. /**
  45892. * Gets the value of the `Share` button
  45893. */
  45894. get buttonShare(): number;
  45895. /**
  45896. * Sets the value of the `Share` button
  45897. */
  45898. set buttonShare(value: number);
  45899. /**
  45900. * Gets the value of the `L1` button
  45901. */
  45902. get buttonL1(): number;
  45903. /**
  45904. * Sets the value of the `L1` button
  45905. */
  45906. set buttonL1(value: number);
  45907. /**
  45908. * Gets the value of the `R1` button
  45909. */
  45910. get buttonR1(): number;
  45911. /**
  45912. * Sets the value of the `R1` button
  45913. */
  45914. set buttonR1(value: number);
  45915. /**
  45916. * Gets the value of the Left joystick
  45917. */
  45918. get buttonLeftStick(): number;
  45919. /**
  45920. * Sets the value of the Left joystick
  45921. */
  45922. set buttonLeftStick(value: number);
  45923. /**
  45924. * Gets the value of the Right joystick
  45925. */
  45926. get buttonRightStick(): number;
  45927. /**
  45928. * Sets the value of the Right joystick
  45929. */
  45930. set buttonRightStick(value: number);
  45931. /**
  45932. * Gets the value of D-pad up
  45933. */
  45934. get dPadUp(): number;
  45935. /**
  45936. * Sets the value of D-pad up
  45937. */
  45938. set dPadUp(value: number);
  45939. /**
  45940. * Gets the value of D-pad down
  45941. */
  45942. get dPadDown(): number;
  45943. /**
  45944. * Sets the value of D-pad down
  45945. */
  45946. set dPadDown(value: number);
  45947. /**
  45948. * Gets the value of D-pad left
  45949. */
  45950. get dPadLeft(): number;
  45951. /**
  45952. * Sets the value of D-pad left
  45953. */
  45954. set dPadLeft(value: number);
  45955. /**
  45956. * Gets the value of D-pad right
  45957. */
  45958. get dPadRight(): number;
  45959. /**
  45960. * Sets the value of D-pad right
  45961. */
  45962. set dPadRight(value: number);
  45963. /**
  45964. * Force the gamepad to synchronize with device values
  45965. */
  45966. update(): void;
  45967. /**
  45968. * Disposes the gamepad
  45969. */
  45970. dispose(): void;
  45971. }
  45972. }
  45973. declare module BABYLON {
  45974. /**
  45975. * Manager for handling gamepads
  45976. */
  45977. export class GamepadManager {
  45978. private _scene?;
  45979. private _babylonGamepads;
  45980. private _oneGamepadConnected;
  45981. /** @hidden */
  45982. _isMonitoring: boolean;
  45983. private _gamepadEventSupported;
  45984. private _gamepadSupport?;
  45985. /**
  45986. * observable to be triggered when the gamepad controller has been connected
  45987. */
  45988. onGamepadConnectedObservable: Observable<Gamepad>;
  45989. /**
  45990. * observable to be triggered when the gamepad controller has been disconnected
  45991. */
  45992. onGamepadDisconnectedObservable: Observable<Gamepad>;
  45993. private _onGamepadConnectedEvent;
  45994. private _onGamepadDisconnectedEvent;
  45995. /**
  45996. * Initializes the gamepad manager
  45997. * @param _scene BabylonJS scene
  45998. */
  45999. constructor(_scene?: Scene | undefined);
  46000. /**
  46001. * The gamepads in the game pad manager
  46002. */
  46003. get gamepads(): Gamepad[];
  46004. /**
  46005. * Get the gamepad controllers based on type
  46006. * @param type The type of gamepad controller
  46007. * @returns Nullable gamepad
  46008. */
  46009. getGamepadByType(type?: number): Nullable<Gamepad>;
  46010. /**
  46011. * Disposes the gamepad manager
  46012. */
  46013. dispose(): void;
  46014. private _addNewGamepad;
  46015. private _startMonitoringGamepads;
  46016. private _stopMonitoringGamepads;
  46017. /** @hidden */
  46018. _checkGamepadsStatus(): void;
  46019. private _updateGamepadObjects;
  46020. }
  46021. }
  46022. declare module BABYLON {
  46023. interface Scene {
  46024. /** @hidden */
  46025. _gamepadManager: Nullable<GamepadManager>;
  46026. /**
  46027. * Gets the gamepad manager associated with the scene
  46028. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  46029. */
  46030. gamepadManager: GamepadManager;
  46031. }
  46032. /**
  46033. * Interface representing a free camera inputs manager
  46034. */
  46035. interface FreeCameraInputsManager {
  46036. /**
  46037. * Adds gamepad input support to the FreeCameraInputsManager.
  46038. * @returns the FreeCameraInputsManager
  46039. */
  46040. addGamepad(): FreeCameraInputsManager;
  46041. }
  46042. /**
  46043. * Interface representing an arc rotate camera inputs manager
  46044. */
  46045. interface ArcRotateCameraInputsManager {
  46046. /**
  46047. * Adds gamepad input support to the ArcRotateCamera InputManager.
  46048. * @returns the camera inputs manager
  46049. */
  46050. addGamepad(): ArcRotateCameraInputsManager;
  46051. }
  46052. /**
  46053. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  46054. */
  46055. export class GamepadSystemSceneComponent implements ISceneComponent {
  46056. /**
  46057. * The component name helpfull to identify the component in the list of scene components.
  46058. */
  46059. readonly name: string;
  46060. /**
  46061. * The scene the component belongs to.
  46062. */
  46063. scene: Scene;
  46064. /**
  46065. * Creates a new instance of the component for the given scene
  46066. * @param scene Defines the scene to register the component in
  46067. */
  46068. constructor(scene: Scene);
  46069. /**
  46070. * Registers the component in a given scene
  46071. */
  46072. register(): void;
  46073. /**
  46074. * Rebuilds the elements related to this component in case of
  46075. * context lost for instance.
  46076. */
  46077. rebuild(): void;
  46078. /**
  46079. * Disposes the component and the associated ressources
  46080. */
  46081. dispose(): void;
  46082. private _beforeCameraUpdate;
  46083. }
  46084. }
  46085. declare module BABYLON {
  46086. /**
  46087. * 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,
  46088. * which still works and will still be found in many Playgrounds.
  46089. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46090. */
  46091. export class UniversalCamera extends TouchCamera {
  46092. /**
  46093. * Defines the gamepad rotation sensiblity.
  46094. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46095. */
  46096. get gamepadAngularSensibility(): number;
  46097. set gamepadAngularSensibility(value: number);
  46098. /**
  46099. * Defines the gamepad move sensiblity.
  46100. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46101. */
  46102. get gamepadMoveSensibility(): number;
  46103. set gamepadMoveSensibility(value: number);
  46104. /**
  46105. * 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,
  46106. * which still works and will still be found in many Playgrounds.
  46107. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46108. * @param name Define the name of the camera in the scene
  46109. * @param position Define the start position of the camera in the scene
  46110. * @param scene Define the scene the camera belongs to
  46111. */
  46112. constructor(name: string, position: Vector3, scene: Scene);
  46113. /**
  46114. * Gets the current object class name.
  46115. * @return the class name
  46116. */
  46117. getClassName(): string;
  46118. }
  46119. }
  46120. declare module BABYLON {
  46121. /**
  46122. * This represents a FPS type of camera. This is only here for back compat purpose.
  46123. * Please use the UniversalCamera instead as both are identical.
  46124. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46125. */
  46126. export class GamepadCamera extends UniversalCamera {
  46127. /**
  46128. * Instantiates a new Gamepad Camera
  46129. * This represents a FPS type of camera. This is only here for back compat purpose.
  46130. * Please use the UniversalCamera instead as both are identical.
  46131. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46132. * @param name Define the name of the camera in the scene
  46133. * @param position Define the start position of the camera in the scene
  46134. * @param scene Define the scene the camera belongs to
  46135. */
  46136. constructor(name: string, position: Vector3, scene: Scene);
  46137. /**
  46138. * Gets the current object class name.
  46139. * @return the class name
  46140. */
  46141. getClassName(): string;
  46142. }
  46143. }
  46144. declare module BABYLON {
  46145. /** @hidden */
  46146. export var passPixelShader: {
  46147. name: string;
  46148. shader: string;
  46149. };
  46150. }
  46151. declare module BABYLON {
  46152. /** @hidden */
  46153. export var passCubePixelShader: {
  46154. name: string;
  46155. shader: string;
  46156. };
  46157. }
  46158. declare module BABYLON {
  46159. /**
  46160. * PassPostProcess which produces an output the same as it's input
  46161. */
  46162. export class PassPostProcess extends PostProcess {
  46163. /**
  46164. * Gets a string identifying the name of the class
  46165. * @returns "PassPostProcess" string
  46166. */
  46167. getClassName(): string;
  46168. /**
  46169. * Creates the PassPostProcess
  46170. * @param name The name of the effect.
  46171. * @param options The required width/height ratio to downsize to before computing the render pass.
  46172. * @param camera The camera to apply the render pass to.
  46173. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46174. * @param engine The engine which the post process will be applied. (default: current engine)
  46175. * @param reusable If the post process can be reused on the same frame. (default: false)
  46176. * @param textureType The type of texture to be used when performing the post processing.
  46177. * @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)
  46178. */
  46179. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46180. /** @hidden */
  46181. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  46182. }
  46183. /**
  46184. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  46185. */
  46186. export class PassCubePostProcess extends PostProcess {
  46187. private _face;
  46188. /**
  46189. * Gets or sets the cube face to display.
  46190. * * 0 is +X
  46191. * * 1 is -X
  46192. * * 2 is +Y
  46193. * * 3 is -Y
  46194. * * 4 is +Z
  46195. * * 5 is -Z
  46196. */
  46197. get face(): number;
  46198. set face(value: number);
  46199. /**
  46200. * Gets a string identifying the name of the class
  46201. * @returns "PassCubePostProcess" string
  46202. */
  46203. getClassName(): string;
  46204. /**
  46205. * Creates the PassCubePostProcess
  46206. * @param name The name of the effect.
  46207. * @param options The required width/height ratio to downsize to before computing the render pass.
  46208. * @param camera The camera to apply the render pass to.
  46209. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46210. * @param engine The engine which the post process will be applied. (default: current engine)
  46211. * @param reusable If the post process can be reused on the same frame. (default: false)
  46212. * @param textureType The type of texture to be used when performing the post processing.
  46213. * @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)
  46214. */
  46215. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46216. /** @hidden */
  46217. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  46218. }
  46219. }
  46220. declare module BABYLON {
  46221. /** @hidden */
  46222. export var anaglyphPixelShader: {
  46223. name: string;
  46224. shader: string;
  46225. };
  46226. }
  46227. declare module BABYLON {
  46228. /**
  46229. * Postprocess used to generate anaglyphic rendering
  46230. */
  46231. export class AnaglyphPostProcess extends PostProcess {
  46232. private _passedProcess;
  46233. /**
  46234. * Gets a string identifying the name of the class
  46235. * @returns "AnaglyphPostProcess" string
  46236. */
  46237. getClassName(): string;
  46238. /**
  46239. * Creates a new AnaglyphPostProcess
  46240. * @param name defines postprocess name
  46241. * @param options defines creation options or target ratio scale
  46242. * @param rigCameras defines cameras using this postprocess
  46243. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  46244. * @param engine defines hosting engine
  46245. * @param reusable defines if the postprocess will be reused multiple times per frame
  46246. */
  46247. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  46248. }
  46249. }
  46250. declare module BABYLON {
  46251. /**
  46252. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  46253. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46254. */
  46255. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  46256. /**
  46257. * Creates a new AnaglyphArcRotateCamera
  46258. * @param name defines camera name
  46259. * @param alpha defines alpha angle (in radians)
  46260. * @param beta defines beta angle (in radians)
  46261. * @param radius defines radius
  46262. * @param target defines camera target
  46263. * @param interaxialDistance defines distance between each color axis
  46264. * @param scene defines the hosting scene
  46265. */
  46266. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  46267. /**
  46268. * Gets camera class name
  46269. * @returns AnaglyphArcRotateCamera
  46270. */
  46271. getClassName(): string;
  46272. }
  46273. }
  46274. declare module BABYLON {
  46275. /**
  46276. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  46277. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46278. */
  46279. export class AnaglyphFreeCamera extends FreeCamera {
  46280. /**
  46281. * Creates a new AnaglyphFreeCamera
  46282. * @param name defines camera name
  46283. * @param position defines initial position
  46284. * @param interaxialDistance defines distance between each color axis
  46285. * @param scene defines the hosting scene
  46286. */
  46287. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46288. /**
  46289. * Gets camera class name
  46290. * @returns AnaglyphFreeCamera
  46291. */
  46292. getClassName(): string;
  46293. }
  46294. }
  46295. declare module BABYLON {
  46296. /**
  46297. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  46298. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46299. */
  46300. export class AnaglyphGamepadCamera extends GamepadCamera {
  46301. /**
  46302. * Creates a new AnaglyphGamepadCamera
  46303. * @param name defines camera name
  46304. * @param position defines initial position
  46305. * @param interaxialDistance defines distance between each color axis
  46306. * @param scene defines the hosting scene
  46307. */
  46308. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46309. /**
  46310. * Gets camera class name
  46311. * @returns AnaglyphGamepadCamera
  46312. */
  46313. getClassName(): string;
  46314. }
  46315. }
  46316. declare module BABYLON {
  46317. /**
  46318. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  46319. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46320. */
  46321. export class AnaglyphUniversalCamera extends UniversalCamera {
  46322. /**
  46323. * Creates a new AnaglyphUniversalCamera
  46324. * @param name defines camera name
  46325. * @param position defines initial position
  46326. * @param interaxialDistance defines distance between each color axis
  46327. * @param scene defines the hosting scene
  46328. */
  46329. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46330. /**
  46331. * Gets camera class name
  46332. * @returns AnaglyphUniversalCamera
  46333. */
  46334. getClassName(): string;
  46335. }
  46336. }
  46337. declare module BABYLON {
  46338. /**
  46339. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  46340. * @see https://doc.babylonjs.com/features/cameras
  46341. */
  46342. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  46343. /**
  46344. * Creates a new StereoscopicArcRotateCamera
  46345. * @param name defines camera name
  46346. * @param alpha defines alpha angle (in radians)
  46347. * @param beta defines beta angle (in radians)
  46348. * @param radius defines radius
  46349. * @param target defines camera target
  46350. * @param interaxialDistance defines distance between each color axis
  46351. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46352. * @param scene defines the hosting scene
  46353. */
  46354. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46355. /**
  46356. * Gets camera class name
  46357. * @returns StereoscopicArcRotateCamera
  46358. */
  46359. getClassName(): string;
  46360. }
  46361. }
  46362. declare module BABYLON {
  46363. /**
  46364. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  46365. * @see https://doc.babylonjs.com/features/cameras
  46366. */
  46367. export class StereoscopicFreeCamera extends FreeCamera {
  46368. /**
  46369. * Creates a new StereoscopicFreeCamera
  46370. * @param name defines camera name
  46371. * @param position defines initial position
  46372. * @param interaxialDistance defines distance between each color axis
  46373. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46374. * @param scene defines the hosting scene
  46375. */
  46376. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46377. /**
  46378. * Gets camera class name
  46379. * @returns StereoscopicFreeCamera
  46380. */
  46381. getClassName(): string;
  46382. }
  46383. }
  46384. declare module BABYLON {
  46385. /**
  46386. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  46387. * @see https://doc.babylonjs.com/features/cameras
  46388. */
  46389. export class StereoscopicGamepadCamera extends GamepadCamera {
  46390. /**
  46391. * Creates a new StereoscopicGamepadCamera
  46392. * @param name defines camera name
  46393. * @param position defines initial position
  46394. * @param interaxialDistance defines distance between each color axis
  46395. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46396. * @param scene defines the hosting scene
  46397. */
  46398. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46399. /**
  46400. * Gets camera class name
  46401. * @returns StereoscopicGamepadCamera
  46402. */
  46403. getClassName(): string;
  46404. }
  46405. }
  46406. declare module BABYLON {
  46407. /**
  46408. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  46409. * @see https://doc.babylonjs.com/features/cameras
  46410. */
  46411. export class StereoscopicUniversalCamera extends UniversalCamera {
  46412. /**
  46413. * Creates a new StereoscopicUniversalCamera
  46414. * @param name defines camera name
  46415. * @param position defines initial position
  46416. * @param interaxialDistance defines distance between each color axis
  46417. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46418. * @param scene defines the hosting scene
  46419. */
  46420. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46421. /**
  46422. * Gets camera class name
  46423. * @returns StereoscopicUniversalCamera
  46424. */
  46425. getClassName(): string;
  46426. }
  46427. }
  46428. declare module BABYLON {
  46429. /**
  46430. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  46431. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46432. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46433. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46434. */
  46435. export class VirtualJoysticksCamera extends FreeCamera {
  46436. /**
  46437. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  46438. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46439. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46440. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46441. * @param name Define the name of the camera in the scene
  46442. * @param position Define the start position of the camera in the scene
  46443. * @param scene Define the scene the camera belongs to
  46444. */
  46445. constructor(name: string, position: Vector3, scene: Scene);
  46446. /**
  46447. * Gets the current object class name.
  46448. * @return the class name
  46449. */
  46450. getClassName(): string;
  46451. }
  46452. }
  46453. declare module BABYLON {
  46454. /**
  46455. * This represents all the required metrics to create a VR camera.
  46456. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  46457. */
  46458. export class VRCameraMetrics {
  46459. /**
  46460. * Define the horizontal resolution off the screen.
  46461. */
  46462. hResolution: number;
  46463. /**
  46464. * Define the vertical resolution off the screen.
  46465. */
  46466. vResolution: number;
  46467. /**
  46468. * Define the horizontal screen size.
  46469. */
  46470. hScreenSize: number;
  46471. /**
  46472. * Define the vertical screen size.
  46473. */
  46474. vScreenSize: number;
  46475. /**
  46476. * Define the vertical screen center position.
  46477. */
  46478. vScreenCenter: number;
  46479. /**
  46480. * Define the distance of the eyes to the screen.
  46481. */
  46482. eyeToScreenDistance: number;
  46483. /**
  46484. * Define the distance between both lenses
  46485. */
  46486. lensSeparationDistance: number;
  46487. /**
  46488. * Define the distance between both viewer's eyes.
  46489. */
  46490. interpupillaryDistance: number;
  46491. /**
  46492. * Define the distortion factor of the VR postprocess.
  46493. * Please, touch with care.
  46494. */
  46495. distortionK: number[];
  46496. /**
  46497. * Define the chromatic aberration correction factors for the VR post process.
  46498. */
  46499. chromaAbCorrection: number[];
  46500. /**
  46501. * Define the scale factor of the post process.
  46502. * The smaller the better but the slower.
  46503. */
  46504. postProcessScaleFactor: number;
  46505. /**
  46506. * Define an offset for the lens center.
  46507. */
  46508. lensCenterOffset: number;
  46509. /**
  46510. * Define if the current vr camera should compensate the distortion of the lense or not.
  46511. */
  46512. compensateDistortion: boolean;
  46513. /**
  46514. * Defines if multiview should be enabled when rendering (Default: false)
  46515. */
  46516. multiviewEnabled: boolean;
  46517. /**
  46518. * Gets the rendering aspect ratio based on the provided resolutions.
  46519. */
  46520. get aspectRatio(): number;
  46521. /**
  46522. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  46523. */
  46524. get aspectRatioFov(): number;
  46525. /**
  46526. * @hidden
  46527. */
  46528. get leftHMatrix(): Matrix;
  46529. /**
  46530. * @hidden
  46531. */
  46532. get rightHMatrix(): Matrix;
  46533. /**
  46534. * @hidden
  46535. */
  46536. get leftPreViewMatrix(): Matrix;
  46537. /**
  46538. * @hidden
  46539. */
  46540. get rightPreViewMatrix(): Matrix;
  46541. /**
  46542. * Get the default VRMetrics based on the most generic setup.
  46543. * @returns the default vr metrics
  46544. */
  46545. static GetDefault(): VRCameraMetrics;
  46546. }
  46547. }
  46548. declare module BABYLON {
  46549. /** @hidden */
  46550. export var vrDistortionCorrectionPixelShader: {
  46551. name: string;
  46552. shader: string;
  46553. };
  46554. }
  46555. declare module BABYLON {
  46556. /**
  46557. * VRDistortionCorrectionPostProcess used for mobile VR
  46558. */
  46559. export class VRDistortionCorrectionPostProcess extends PostProcess {
  46560. private _isRightEye;
  46561. private _distortionFactors;
  46562. private _postProcessScaleFactor;
  46563. private _lensCenterOffset;
  46564. private _scaleIn;
  46565. private _scaleFactor;
  46566. private _lensCenter;
  46567. /**
  46568. * Gets a string identifying the name of the class
  46569. * @returns "VRDistortionCorrectionPostProcess" string
  46570. */
  46571. getClassName(): string;
  46572. /**
  46573. * Initializes the VRDistortionCorrectionPostProcess
  46574. * @param name The name of the effect.
  46575. * @param camera The camera to apply the render pass to.
  46576. * @param isRightEye If this is for the right eye distortion
  46577. * @param vrMetrics All the required metrics for the VR camera
  46578. */
  46579. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  46580. }
  46581. }
  46582. declare module BABYLON {
  46583. /**
  46584. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  46585. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46586. */
  46587. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  46588. /**
  46589. * Creates a new VRDeviceOrientationArcRotateCamera
  46590. * @param name defines camera name
  46591. * @param alpha defines the camera rotation along the logitudinal axis
  46592. * @param beta defines the camera rotation along the latitudinal axis
  46593. * @param radius defines the camera distance from its target
  46594. * @param target defines the camera target
  46595. * @param scene defines the scene the camera belongs to
  46596. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46597. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46598. */
  46599. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46600. /**
  46601. * Gets camera class name
  46602. * @returns VRDeviceOrientationArcRotateCamera
  46603. */
  46604. getClassName(): string;
  46605. }
  46606. }
  46607. declare module BABYLON {
  46608. /**
  46609. * Camera used to simulate VR rendering (based on FreeCamera)
  46610. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46611. */
  46612. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  46613. /**
  46614. * Creates a new VRDeviceOrientationFreeCamera
  46615. * @param name defines camera name
  46616. * @param position defines the start position of the camera
  46617. * @param scene defines the scene the camera belongs to
  46618. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46619. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46620. */
  46621. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46622. /**
  46623. * Gets camera class name
  46624. * @returns VRDeviceOrientationFreeCamera
  46625. */
  46626. getClassName(): string;
  46627. }
  46628. }
  46629. declare module BABYLON {
  46630. /**
  46631. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  46632. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46633. */
  46634. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  46635. /**
  46636. * Creates a new VRDeviceOrientationGamepadCamera
  46637. * @param name defines camera name
  46638. * @param position defines the start position of the camera
  46639. * @param scene defines the scene the camera belongs to
  46640. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46641. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46642. */
  46643. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46644. /**
  46645. * Gets camera class name
  46646. * @returns VRDeviceOrientationGamepadCamera
  46647. */
  46648. getClassName(): string;
  46649. }
  46650. }
  46651. declare module BABYLON {
  46652. /**
  46653. * A class extending Texture allowing drawing on a texture
  46654. * @see https://doc.babylonjs.com/how_to/dynamictexture
  46655. */
  46656. export class DynamicTexture extends Texture {
  46657. private _generateMipMaps;
  46658. private _canvas;
  46659. private _context;
  46660. /**
  46661. * Creates a DynamicTexture
  46662. * @param name defines the name of the texture
  46663. * @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
  46664. * @param scene defines the scene where you want the texture
  46665. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  46666. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  46667. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  46668. */
  46669. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  46670. /**
  46671. * Get the current class name of the texture useful for serialization or dynamic coding.
  46672. * @returns "DynamicTexture"
  46673. */
  46674. getClassName(): string;
  46675. /**
  46676. * Gets the current state of canRescale
  46677. */
  46678. get canRescale(): boolean;
  46679. private _recreate;
  46680. /**
  46681. * Scales the texture
  46682. * @param ratio the scale factor to apply to both width and height
  46683. */
  46684. scale(ratio: number): void;
  46685. /**
  46686. * Resizes the texture
  46687. * @param width the new width
  46688. * @param height the new height
  46689. */
  46690. scaleTo(width: number, height: number): void;
  46691. /**
  46692. * Gets the context of the canvas used by the texture
  46693. * @returns the canvas context of the dynamic texture
  46694. */
  46695. getContext(): CanvasRenderingContext2D;
  46696. /**
  46697. * Clears the texture
  46698. */
  46699. clear(): void;
  46700. /**
  46701. * Updates the texture
  46702. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46703. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  46704. */
  46705. update(invertY?: boolean, premulAlpha?: boolean): void;
  46706. /**
  46707. * Draws text onto the texture
  46708. * @param text defines the text to be drawn
  46709. * @param x defines the placement of the text from the left
  46710. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  46711. * @param font defines the font to be used with font-style, font-size, font-name
  46712. * @param color defines the color used for the text
  46713. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  46714. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46715. * @param update defines whether texture is immediately update (default is true)
  46716. */
  46717. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  46718. /**
  46719. * Clones the texture
  46720. * @returns the clone of the texture.
  46721. */
  46722. clone(): DynamicTexture;
  46723. /**
  46724. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  46725. * @returns a serialized dynamic texture object
  46726. */
  46727. serialize(): any;
  46728. private _IsCanvasElement;
  46729. /** @hidden */
  46730. _rebuild(): void;
  46731. }
  46732. }
  46733. declare module BABYLON {
  46734. /**
  46735. * Class containing static functions to help procedurally build meshes
  46736. */
  46737. export class GroundBuilder {
  46738. /**
  46739. * Creates a ground mesh
  46740. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  46741. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  46742. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46743. * @param name defines the name of the mesh
  46744. * @param options defines the options used to create the mesh
  46745. * @param scene defines the hosting scene
  46746. * @returns the ground mesh
  46747. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  46748. */
  46749. static CreateGround(name: string, options: {
  46750. width?: number;
  46751. height?: number;
  46752. subdivisions?: number;
  46753. subdivisionsX?: number;
  46754. subdivisionsY?: number;
  46755. updatable?: boolean;
  46756. }, scene: any): Mesh;
  46757. /**
  46758. * Creates a tiled ground mesh
  46759. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  46760. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  46761. * * 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
  46762. * * 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
  46763. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46764. * @param name defines the name of the mesh
  46765. * @param options defines the options used to create the mesh
  46766. * @param scene defines the hosting scene
  46767. * @returns the tiled ground mesh
  46768. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  46769. */
  46770. static CreateTiledGround(name: string, options: {
  46771. xmin: number;
  46772. zmin: number;
  46773. xmax: number;
  46774. zmax: number;
  46775. subdivisions?: {
  46776. w: number;
  46777. h: number;
  46778. };
  46779. precision?: {
  46780. w: number;
  46781. h: number;
  46782. };
  46783. updatable?: boolean;
  46784. }, scene?: Nullable<Scene>): Mesh;
  46785. /**
  46786. * Creates a ground mesh from a height map
  46787. * * The parameter `url` sets the URL of the height map image resource.
  46788. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  46789. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  46790. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  46791. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  46792. * * 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.
  46793. * * 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).
  46794. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  46795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46796. * @param name defines the name of the mesh
  46797. * @param url defines the url to the height map
  46798. * @param options defines the options used to create the mesh
  46799. * @param scene defines the hosting scene
  46800. * @returns the ground mesh
  46801. * @see https://doc.babylonjs.com/babylon101/height_map
  46802. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  46803. */
  46804. static CreateGroundFromHeightMap(name: string, url: string, options: {
  46805. width?: number;
  46806. height?: number;
  46807. subdivisions?: number;
  46808. minHeight?: number;
  46809. maxHeight?: number;
  46810. colorFilter?: Color3;
  46811. alphaFilter?: number;
  46812. updatable?: boolean;
  46813. onReady?: (mesh: GroundMesh) => void;
  46814. }, scene?: Nullable<Scene>): GroundMesh;
  46815. }
  46816. }
  46817. declare module BABYLON {
  46818. /**
  46819. * Class containing static functions to help procedurally build meshes
  46820. */
  46821. export class TorusBuilder {
  46822. /**
  46823. * Creates a torus mesh
  46824. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  46825. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  46826. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  46827. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46828. * * 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
  46829. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46830. * @param name defines the name of the mesh
  46831. * @param options defines the options used to create the mesh
  46832. * @param scene defines the hosting scene
  46833. * @returns the torus mesh
  46834. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  46835. */
  46836. static CreateTorus(name: string, options: {
  46837. diameter?: number;
  46838. thickness?: number;
  46839. tessellation?: number;
  46840. updatable?: boolean;
  46841. sideOrientation?: number;
  46842. frontUVs?: Vector4;
  46843. backUVs?: Vector4;
  46844. }, scene: any): Mesh;
  46845. }
  46846. }
  46847. declare module BABYLON {
  46848. /**
  46849. * Class containing static functions to help procedurally build meshes
  46850. */
  46851. export class CylinderBuilder {
  46852. /**
  46853. * Creates a cylinder or a cone mesh
  46854. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  46855. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  46856. * * 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.
  46857. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  46858. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  46859. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  46860. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  46861. * * 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).
  46862. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  46863. * * 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).
  46864. * * 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
  46865. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  46866. * * 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
  46867. * * 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.
  46868. * * If `enclose` is false, a ring surface is one element.
  46869. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  46870. * * 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
  46871. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46872. * * 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
  46873. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46874. * @param name defines the name of the mesh
  46875. * @param options defines the options used to create the mesh
  46876. * @param scene defines the hosting scene
  46877. * @returns the cylinder mesh
  46878. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  46879. */
  46880. static CreateCylinder(name: string, options: {
  46881. height?: number;
  46882. diameterTop?: number;
  46883. diameterBottom?: number;
  46884. diameter?: number;
  46885. tessellation?: number;
  46886. subdivisions?: number;
  46887. arc?: number;
  46888. faceColors?: Color4[];
  46889. faceUV?: Vector4[];
  46890. updatable?: boolean;
  46891. hasRings?: boolean;
  46892. enclose?: boolean;
  46893. cap?: number;
  46894. sideOrientation?: number;
  46895. frontUVs?: Vector4;
  46896. backUVs?: Vector4;
  46897. }, scene: any): Mesh;
  46898. }
  46899. }
  46900. declare module BABYLON {
  46901. /**
  46902. * States of the webXR experience
  46903. */
  46904. export enum WebXRState {
  46905. /**
  46906. * Transitioning to being in XR mode
  46907. */
  46908. ENTERING_XR = 0,
  46909. /**
  46910. * Transitioning to non XR mode
  46911. */
  46912. EXITING_XR = 1,
  46913. /**
  46914. * In XR mode and presenting
  46915. */
  46916. IN_XR = 2,
  46917. /**
  46918. * Not entered XR mode
  46919. */
  46920. NOT_IN_XR = 3
  46921. }
  46922. /**
  46923. * Abstraction of the XR render target
  46924. */
  46925. export interface WebXRRenderTarget extends IDisposable {
  46926. /**
  46927. * xrpresent context of the canvas which can be used to display/mirror xr content
  46928. */
  46929. canvasContext: WebGLRenderingContext;
  46930. /**
  46931. * xr layer for the canvas
  46932. */
  46933. xrLayer: Nullable<XRWebGLLayer>;
  46934. /**
  46935. * Initializes the xr layer for the session
  46936. * @param xrSession xr session
  46937. * @returns a promise that will resolve once the XR Layer has been created
  46938. */
  46939. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46940. }
  46941. }
  46942. declare module BABYLON {
  46943. /**
  46944. * COnfiguration object for WebXR output canvas
  46945. */
  46946. export class WebXRManagedOutputCanvasOptions {
  46947. /**
  46948. * An optional canvas in case you wish to create it yourself and provide it here.
  46949. * If not provided, a new canvas will be created
  46950. */
  46951. canvasElement?: HTMLCanvasElement;
  46952. /**
  46953. * Options for this XR Layer output
  46954. */
  46955. canvasOptions?: XRWebGLLayerOptions;
  46956. /**
  46957. * CSS styling for a newly created canvas (if not provided)
  46958. */
  46959. newCanvasCssStyle?: string;
  46960. /**
  46961. * Get the default values of the configuration object
  46962. * @param engine defines the engine to use (can be null)
  46963. * @returns default values of this configuration object
  46964. */
  46965. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  46966. }
  46967. /**
  46968. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  46969. */
  46970. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  46971. private _options;
  46972. private _canvas;
  46973. private _engine;
  46974. private _originalCanvasSize;
  46975. /**
  46976. * Rendering context of the canvas which can be used to display/mirror xr content
  46977. */
  46978. canvasContext: WebGLRenderingContext;
  46979. /**
  46980. * xr layer for the canvas
  46981. */
  46982. xrLayer: Nullable<XRWebGLLayer>;
  46983. /**
  46984. * Obseervers registered here will be triggered when the xr layer was initialized
  46985. */
  46986. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  46987. /**
  46988. * Initializes the canvas to be added/removed upon entering/exiting xr
  46989. * @param _xrSessionManager The XR Session manager
  46990. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  46991. */
  46992. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  46993. /**
  46994. * Disposes of the object
  46995. */
  46996. dispose(): void;
  46997. /**
  46998. * Initializes the xr layer for the session
  46999. * @param xrSession xr session
  47000. * @returns a promise that will resolve once the XR Layer has been created
  47001. */
  47002. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  47003. private _addCanvas;
  47004. private _removeCanvas;
  47005. private _setCanvasSize;
  47006. private _setManagedOutputCanvas;
  47007. }
  47008. }
  47009. declare module BABYLON {
  47010. /**
  47011. * Manages an XRSession to work with Babylon's engine
  47012. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  47013. */
  47014. export class WebXRSessionManager implements IDisposable {
  47015. /** The scene which the session should be created for */
  47016. scene: Scene;
  47017. private _referenceSpace;
  47018. private _rttProvider;
  47019. private _sessionEnded;
  47020. private _xrNavigator;
  47021. private baseLayer;
  47022. /**
  47023. * The base reference space from which the session started. good if you want to reset your
  47024. * reference space
  47025. */
  47026. baseReferenceSpace: XRReferenceSpace;
  47027. /**
  47028. * Current XR frame
  47029. */
  47030. currentFrame: Nullable<XRFrame>;
  47031. /** WebXR timestamp updated every frame */
  47032. currentTimestamp: number;
  47033. /**
  47034. * Used just in case of a failure to initialize an immersive session.
  47035. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  47036. */
  47037. defaultHeightCompensation: number;
  47038. /**
  47039. * Fires every time a new xrFrame arrives which can be used to update the camera
  47040. */
  47041. onXRFrameObservable: Observable<XRFrame>;
  47042. /**
  47043. * Fires when the reference space changed
  47044. */
  47045. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  47046. /**
  47047. * Fires when the xr session is ended either by the device or manually done
  47048. */
  47049. onXRSessionEnded: Observable<any>;
  47050. /**
  47051. * Fires when the xr session is ended either by the device or manually done
  47052. */
  47053. onXRSessionInit: Observable<XRSession>;
  47054. /**
  47055. * Underlying xr session
  47056. */
  47057. session: XRSession;
  47058. /**
  47059. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  47060. * or get the offset the player is currently at.
  47061. */
  47062. viewerReferenceSpace: XRReferenceSpace;
  47063. /**
  47064. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  47065. * @param scene The scene which the session should be created for
  47066. */
  47067. constructor(
  47068. /** The scene which the session should be created for */
  47069. scene: Scene);
  47070. /**
  47071. * The current reference space used in this session. This reference space can constantly change!
  47072. * It is mainly used to offset the camera's position.
  47073. */
  47074. get referenceSpace(): XRReferenceSpace;
  47075. /**
  47076. * Set a new reference space and triggers the observable
  47077. */
  47078. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  47079. /**
  47080. * Disposes of the session manager
  47081. */
  47082. dispose(): void;
  47083. /**
  47084. * Stops the xrSession and restores the render loop
  47085. * @returns Promise which resolves after it exits XR
  47086. */
  47087. exitXRAsync(): Promise<void>;
  47088. /**
  47089. * Gets the correct render target texture to be rendered this frame for this eye
  47090. * @param eye the eye for which to get the render target
  47091. * @returns the render target for the specified eye
  47092. */
  47093. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  47094. /**
  47095. * Creates a WebXRRenderTarget object for the XR session
  47096. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  47097. * @param options optional options to provide when creating a new render target
  47098. * @returns a WebXR render target to which the session can render
  47099. */
  47100. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  47101. /**
  47102. * Initializes the manager
  47103. * After initialization enterXR can be called to start an XR session
  47104. * @returns Promise which resolves after it is initialized
  47105. */
  47106. initializeAsync(): Promise<void>;
  47107. /**
  47108. * Initializes an xr session
  47109. * @param xrSessionMode mode to initialize
  47110. * @param xrSessionInit defines optional and required values to pass to the session builder
  47111. * @returns a promise which will resolve once the session has been initialized
  47112. */
  47113. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  47114. /**
  47115. * Checks if a session would be supported for the creation options specified
  47116. * @param sessionMode session mode to check if supported eg. immersive-vr
  47117. * @returns A Promise that resolves to true if supported and false if not
  47118. */
  47119. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47120. /**
  47121. * Resets the reference space to the one started the session
  47122. */
  47123. resetReferenceSpace(): void;
  47124. /**
  47125. * Starts rendering to the xr layer
  47126. */
  47127. runXRRenderLoop(): void;
  47128. /**
  47129. * Sets the reference space on the xr session
  47130. * @param referenceSpaceType space to set
  47131. * @returns a promise that will resolve once the reference space has been set
  47132. */
  47133. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  47134. /**
  47135. * Updates the render state of the session
  47136. * @param state state to set
  47137. * @returns a promise that resolves once the render state has been updated
  47138. */
  47139. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  47140. /**
  47141. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  47142. * @param sessionMode defines the session to test
  47143. * @returns a promise with boolean as final value
  47144. */
  47145. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47146. private _createRenderTargetTexture;
  47147. }
  47148. }
  47149. declare module BABYLON {
  47150. /**
  47151. * WebXR Camera which holds the views for the xrSession
  47152. * @see https://doc.babylonjs.com/how_to/webxr_camera
  47153. */
  47154. export class WebXRCamera extends FreeCamera {
  47155. private _xrSessionManager;
  47156. private _firstFrame;
  47157. private _referenceQuaternion;
  47158. private _referencedPosition;
  47159. private _xrInvPositionCache;
  47160. private _xrInvQuaternionCache;
  47161. /**
  47162. * Observable raised before camera teleportation
  47163. */
  47164. onBeforeCameraTeleport: Observable<Vector3>;
  47165. /**
  47166. * Observable raised after camera teleportation
  47167. */
  47168. onAfterCameraTeleport: Observable<Vector3>;
  47169. /**
  47170. * Should position compensation execute on first frame.
  47171. * This is used when copying the position from a native (non XR) camera
  47172. */
  47173. compensateOnFirstFrame: boolean;
  47174. /**
  47175. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  47176. * @param name the name of the camera
  47177. * @param scene the scene to add the camera to
  47178. * @param _xrSessionManager a constructed xr session manager
  47179. */
  47180. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  47181. /**
  47182. * Return the user's height, unrelated to the current ground.
  47183. * This will be the y position of this camera, when ground level is 0.
  47184. */
  47185. get realWorldHeight(): number;
  47186. /** @hidden */
  47187. _updateForDualEyeDebugging(): void;
  47188. /**
  47189. * Sets this camera's transformation based on a non-vr camera
  47190. * @param otherCamera the non-vr camera to copy the transformation from
  47191. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  47192. */
  47193. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  47194. /**
  47195. * Gets the current instance class name ("WebXRCamera").
  47196. * @returns the class name
  47197. */
  47198. getClassName(): string;
  47199. private _rotate180;
  47200. private _updateFromXRSession;
  47201. private _updateNumberOfRigCameras;
  47202. private _updateReferenceSpace;
  47203. private _updateReferenceSpaceOffset;
  47204. }
  47205. }
  47206. declare module BABYLON {
  47207. /**
  47208. * Defining the interface required for a (webxr) feature
  47209. */
  47210. export interface IWebXRFeature extends IDisposable {
  47211. /**
  47212. * Is this feature attached
  47213. */
  47214. attached: boolean;
  47215. /**
  47216. * Should auto-attach be disabled?
  47217. */
  47218. disableAutoAttach: boolean;
  47219. /**
  47220. * Attach the feature to the session
  47221. * Will usually be called by the features manager
  47222. *
  47223. * @param force should attachment be forced (even when already attached)
  47224. * @returns true if successful.
  47225. */
  47226. attach(force?: boolean): boolean;
  47227. /**
  47228. * Detach the feature from the session
  47229. * Will usually be called by the features manager
  47230. *
  47231. * @returns true if successful.
  47232. */
  47233. detach(): boolean;
  47234. /**
  47235. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  47236. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  47237. *
  47238. * @returns whether or not the feature is compatible in this environment
  47239. */
  47240. isCompatible(): boolean;
  47241. /**
  47242. * Was this feature disposed;
  47243. */
  47244. isDisposed: boolean;
  47245. /**
  47246. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  47247. */
  47248. xrNativeFeatureName?: string;
  47249. /**
  47250. * A list of (Babylon WebXR) features this feature depends on
  47251. */
  47252. dependsOn?: string[];
  47253. }
  47254. /**
  47255. * A list of the currently available features without referencing them
  47256. */
  47257. export class WebXRFeatureName {
  47258. /**
  47259. * The name of the anchor system feature
  47260. */
  47261. static readonly ANCHOR_SYSTEM: string;
  47262. /**
  47263. * The name of the background remover feature
  47264. */
  47265. static readonly BACKGROUND_REMOVER: string;
  47266. /**
  47267. * The name of the hit test feature
  47268. */
  47269. static readonly HIT_TEST: string;
  47270. /**
  47271. * physics impostors for xr controllers feature
  47272. */
  47273. static readonly PHYSICS_CONTROLLERS: string;
  47274. /**
  47275. * The name of the plane detection feature
  47276. */
  47277. static readonly PLANE_DETECTION: string;
  47278. /**
  47279. * The name of the pointer selection feature
  47280. */
  47281. static readonly POINTER_SELECTION: string;
  47282. /**
  47283. * The name of the teleportation feature
  47284. */
  47285. static readonly TELEPORTATION: string;
  47286. /**
  47287. * The name of the feature points feature.
  47288. */
  47289. static readonly FEATURE_POINTS: string;
  47290. /**
  47291. * The name of the hand tracking feature.
  47292. */
  47293. static readonly HAND_TRACKING: string;
  47294. }
  47295. /**
  47296. * Defining the constructor of a feature. Used to register the modules.
  47297. */
  47298. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  47299. /**
  47300. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  47301. * It is mainly used in AR sessions.
  47302. *
  47303. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  47304. */
  47305. export class WebXRFeaturesManager implements IDisposable {
  47306. private _xrSessionManager;
  47307. private static readonly _AvailableFeatures;
  47308. private _features;
  47309. /**
  47310. * constructs a new features manages.
  47311. *
  47312. * @param _xrSessionManager an instance of WebXRSessionManager
  47313. */
  47314. constructor(_xrSessionManager: WebXRSessionManager);
  47315. /**
  47316. * Used to register a module. After calling this function a developer can use this feature in the scene.
  47317. * Mainly used internally.
  47318. *
  47319. * @param featureName the name of the feature to register
  47320. * @param constructorFunction the function used to construct the module
  47321. * @param version the (babylon) version of the module
  47322. * @param stable is that a stable version of this module
  47323. */
  47324. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  47325. /**
  47326. * Returns a constructor of a specific feature.
  47327. *
  47328. * @param featureName the name of the feature to construct
  47329. * @param version the version of the feature to load
  47330. * @param xrSessionManager the xrSessionManager. Used to construct the module
  47331. * @param options optional options provided to the module.
  47332. * @returns a function that, when called, will return a new instance of this feature
  47333. */
  47334. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  47335. /**
  47336. * Can be used to return the list of features currently registered
  47337. *
  47338. * @returns an Array of available features
  47339. */
  47340. static GetAvailableFeatures(): string[];
  47341. /**
  47342. * Gets the versions available for a specific feature
  47343. * @param featureName the name of the feature
  47344. * @returns an array with the available versions
  47345. */
  47346. static GetAvailableVersions(featureName: string): string[];
  47347. /**
  47348. * Return the latest unstable version of this feature
  47349. * @param featureName the name of the feature to search
  47350. * @returns the version number. if not found will return -1
  47351. */
  47352. static GetLatestVersionOfFeature(featureName: string): number;
  47353. /**
  47354. * Return the latest stable version of this feature
  47355. * @param featureName the name of the feature to search
  47356. * @returns the version number. if not found will return -1
  47357. */
  47358. static GetStableVersionOfFeature(featureName: string): number;
  47359. /**
  47360. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  47361. * Can be used during a session to start a feature
  47362. * @param featureName the name of feature to attach
  47363. */
  47364. attachFeature(featureName: string): void;
  47365. /**
  47366. * Can be used inside a session or when the session ends to detach a specific feature
  47367. * @param featureName the name of the feature to detach
  47368. */
  47369. detachFeature(featureName: string): void;
  47370. /**
  47371. * Used to disable an already-enabled feature
  47372. * The feature will be disposed and will be recreated once enabled.
  47373. * @param featureName the feature to disable
  47374. * @returns true if disable was successful
  47375. */
  47376. disableFeature(featureName: string | {
  47377. Name: string;
  47378. }): boolean;
  47379. /**
  47380. * dispose this features manager
  47381. */
  47382. dispose(): void;
  47383. /**
  47384. * 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.
  47385. * 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.
  47386. *
  47387. * @param featureName the name of the feature to load or the class of the feature
  47388. * @param version optional version to load. if not provided the latest version will be enabled
  47389. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  47390. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  47391. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  47392. * @returns a new constructed feature or throws an error if feature not found.
  47393. */
  47394. enableFeature(featureName: string | {
  47395. Name: string;
  47396. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  47397. /**
  47398. * get the implementation of an enabled feature.
  47399. * @param featureName the name of the feature to load
  47400. * @returns the feature class, if found
  47401. */
  47402. getEnabledFeature(featureName: string): IWebXRFeature;
  47403. /**
  47404. * Get the list of enabled features
  47405. * @returns an array of enabled features
  47406. */
  47407. getEnabledFeatures(): string[];
  47408. /**
  47409. * This function will exten the session creation configuration object with enabled features.
  47410. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  47411. * according to the defined "required" variable, provided during enableFeature call
  47412. * @param xrSessionInit the xr Session init object to extend
  47413. *
  47414. * @returns an extended XRSessionInit object
  47415. */
  47416. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  47417. }
  47418. }
  47419. declare module BABYLON {
  47420. /**
  47421. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  47422. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  47423. */
  47424. export class WebXRExperienceHelper implements IDisposable {
  47425. private scene;
  47426. private _nonVRCamera;
  47427. private _originalSceneAutoClear;
  47428. private _supported;
  47429. /**
  47430. * Camera used to render xr content
  47431. */
  47432. camera: WebXRCamera;
  47433. /** A features manager for this xr session */
  47434. featuresManager: WebXRFeaturesManager;
  47435. /**
  47436. * Observers registered here will be triggered after the camera's initial transformation is set
  47437. * This can be used to set a different ground level or an extra rotation.
  47438. *
  47439. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  47440. * to the position set after this observable is done executing.
  47441. */
  47442. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  47443. /**
  47444. * Fires when the state of the experience helper has changed
  47445. */
  47446. onStateChangedObservable: Observable<WebXRState>;
  47447. /** Session manager used to keep track of xr session */
  47448. sessionManager: WebXRSessionManager;
  47449. /**
  47450. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  47451. */
  47452. state: WebXRState;
  47453. /**
  47454. * Creates a WebXRExperienceHelper
  47455. * @param scene The scene the helper should be created in
  47456. */
  47457. private constructor();
  47458. /**
  47459. * Creates the experience helper
  47460. * @param scene the scene to attach the experience helper to
  47461. * @returns a promise for the experience helper
  47462. */
  47463. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  47464. /**
  47465. * Disposes of the experience helper
  47466. */
  47467. dispose(): void;
  47468. /**
  47469. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  47470. * @param sessionMode options for the XR session
  47471. * @param referenceSpaceType frame of reference of the XR session
  47472. * @param renderTarget the output canvas that will be used to enter XR mode
  47473. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  47474. * @returns promise that resolves after xr mode has entered
  47475. */
  47476. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  47477. /**
  47478. * Exits XR mode and returns the scene to its original state
  47479. * @returns promise that resolves after xr mode has exited
  47480. */
  47481. exitXRAsync(): Promise<void>;
  47482. private _nonXRToXRCamera;
  47483. private _setState;
  47484. }
  47485. }
  47486. declare module BABYLON {
  47487. /**
  47488. * X-Y values for axes in WebXR
  47489. */
  47490. export interface IWebXRMotionControllerAxesValue {
  47491. /**
  47492. * The value of the x axis
  47493. */
  47494. x: number;
  47495. /**
  47496. * The value of the y-axis
  47497. */
  47498. y: number;
  47499. }
  47500. /**
  47501. * changed / previous values for the values of this component
  47502. */
  47503. export interface IWebXRMotionControllerComponentChangesValues<T> {
  47504. /**
  47505. * current (this frame) value
  47506. */
  47507. current: T;
  47508. /**
  47509. * previous (last change) value
  47510. */
  47511. previous: T;
  47512. }
  47513. /**
  47514. * Represents changes in the component between current frame and last values recorded
  47515. */
  47516. export interface IWebXRMotionControllerComponentChanges {
  47517. /**
  47518. * will be populated with previous and current values if axes changed
  47519. */
  47520. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  47521. /**
  47522. * will be populated with previous and current values if pressed changed
  47523. */
  47524. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47525. /**
  47526. * will be populated with previous and current values if touched changed
  47527. */
  47528. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47529. /**
  47530. * will be populated with previous and current values if value changed
  47531. */
  47532. value?: IWebXRMotionControllerComponentChangesValues<number>;
  47533. }
  47534. /**
  47535. * This class represents a single component (for example button or thumbstick) of a motion controller
  47536. */
  47537. export class WebXRControllerComponent implements IDisposable {
  47538. /**
  47539. * the id of this component
  47540. */
  47541. id: string;
  47542. /**
  47543. * the type of the component
  47544. */
  47545. type: MotionControllerComponentType;
  47546. private _buttonIndex;
  47547. private _axesIndices;
  47548. private _axes;
  47549. private _changes;
  47550. private _currentValue;
  47551. private _hasChanges;
  47552. private _pressed;
  47553. private _touched;
  47554. /**
  47555. * button component type
  47556. */
  47557. static BUTTON_TYPE: MotionControllerComponentType;
  47558. /**
  47559. * squeeze component type
  47560. */
  47561. static SQUEEZE_TYPE: MotionControllerComponentType;
  47562. /**
  47563. * Thumbstick component type
  47564. */
  47565. static THUMBSTICK_TYPE: MotionControllerComponentType;
  47566. /**
  47567. * Touchpad component type
  47568. */
  47569. static TOUCHPAD_TYPE: MotionControllerComponentType;
  47570. /**
  47571. * trigger component type
  47572. */
  47573. static TRIGGER_TYPE: MotionControllerComponentType;
  47574. /**
  47575. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  47576. * the axes data changes
  47577. */
  47578. onAxisValueChangedObservable: Observable<{
  47579. x: number;
  47580. y: number;
  47581. }>;
  47582. /**
  47583. * Observers registered here will be triggered when the state of a button changes
  47584. * State change is either pressed / touched / value
  47585. */
  47586. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  47587. /**
  47588. * Creates a new component for a motion controller.
  47589. * It is created by the motion controller itself
  47590. *
  47591. * @param id the id of this component
  47592. * @param type the type of the component
  47593. * @param _buttonIndex index in the buttons array of the gamepad
  47594. * @param _axesIndices indices of the values in the axes array of the gamepad
  47595. */
  47596. constructor(
  47597. /**
  47598. * the id of this component
  47599. */
  47600. id: string,
  47601. /**
  47602. * the type of the component
  47603. */
  47604. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  47605. /**
  47606. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  47607. */
  47608. get axes(): IWebXRMotionControllerAxesValue;
  47609. /**
  47610. * Get the changes. Elements will be populated only if they changed with their previous and current value
  47611. */
  47612. get changes(): IWebXRMotionControllerComponentChanges;
  47613. /**
  47614. * Return whether or not the component changed the last frame
  47615. */
  47616. get hasChanges(): boolean;
  47617. /**
  47618. * is the button currently pressed
  47619. */
  47620. get pressed(): boolean;
  47621. /**
  47622. * is the button currently touched
  47623. */
  47624. get touched(): boolean;
  47625. /**
  47626. * Get the current value of this component
  47627. */
  47628. get value(): number;
  47629. /**
  47630. * Dispose this component
  47631. */
  47632. dispose(): void;
  47633. /**
  47634. * Are there axes correlating to this component
  47635. * @return true is axes data is available
  47636. */
  47637. isAxes(): boolean;
  47638. /**
  47639. * Is this component a button (hence - pressable)
  47640. * @returns true if can be pressed
  47641. */
  47642. isButton(): boolean;
  47643. /**
  47644. * update this component using the gamepad object it is in. Called on every frame
  47645. * @param nativeController the native gamepad controller object
  47646. */
  47647. update(nativeController: IMinimalMotionControllerObject): void;
  47648. }
  47649. }
  47650. declare module BABYLON {
  47651. /**
  47652. * Interface used to represent data loading progression
  47653. */
  47654. export interface ISceneLoaderProgressEvent {
  47655. /**
  47656. * Defines if data length to load can be evaluated
  47657. */
  47658. readonly lengthComputable: boolean;
  47659. /**
  47660. * Defines the loaded data length
  47661. */
  47662. readonly loaded: number;
  47663. /**
  47664. * Defines the data length to load
  47665. */
  47666. readonly total: number;
  47667. }
  47668. /**
  47669. * Interface used by SceneLoader plugins to define supported file extensions
  47670. */
  47671. export interface ISceneLoaderPluginExtensions {
  47672. /**
  47673. * Defines the list of supported extensions
  47674. */
  47675. [extension: string]: {
  47676. isBinary: boolean;
  47677. };
  47678. }
  47679. /**
  47680. * Interface used by SceneLoader plugin factory
  47681. */
  47682. export interface ISceneLoaderPluginFactory {
  47683. /**
  47684. * Defines the name of the factory
  47685. */
  47686. name: string;
  47687. /**
  47688. * Function called to create a new plugin
  47689. * @return the new plugin
  47690. */
  47691. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  47692. /**
  47693. * The callback that returns true if the data can be directly loaded.
  47694. * @param data string containing the file data
  47695. * @returns if the data can be loaded directly
  47696. */
  47697. canDirectLoad?(data: string): boolean;
  47698. }
  47699. /**
  47700. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  47701. */
  47702. export interface ISceneLoaderPluginBase {
  47703. /**
  47704. * The friendly name of this plugin.
  47705. */
  47706. name: string;
  47707. /**
  47708. * The file extensions supported by this plugin.
  47709. */
  47710. extensions: string | ISceneLoaderPluginExtensions;
  47711. /**
  47712. * The callback called when loading from a url.
  47713. * @param scene scene loading this url
  47714. * @param url url to load
  47715. * @param onSuccess callback called when the file successfully loads
  47716. * @param onProgress callback called while file is loading (if the server supports this mode)
  47717. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  47718. * @param onError callback called when the file fails to load
  47719. * @returns a file request object
  47720. */
  47721. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47722. /**
  47723. * The callback called when loading from a file object.
  47724. * @param scene scene loading this file
  47725. * @param file defines the file to load
  47726. * @param onSuccess defines the callback to call when data is loaded
  47727. * @param onProgress defines the callback to call during loading process
  47728. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  47729. * @param onError defines the callback to call when an error occurs
  47730. * @returns a file request object
  47731. */
  47732. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47733. /**
  47734. * The callback that returns true if the data can be directly loaded.
  47735. * @param data string containing the file data
  47736. * @returns if the data can be loaded directly
  47737. */
  47738. canDirectLoad?(data: string): boolean;
  47739. /**
  47740. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  47741. * @param scene scene loading this data
  47742. * @param data string containing the data
  47743. * @returns data to pass to the plugin
  47744. */
  47745. directLoad?(scene: Scene, data: string): any;
  47746. /**
  47747. * The callback that allows custom handling of the root url based on the response url.
  47748. * @param rootUrl the original root url
  47749. * @param responseURL the response url if available
  47750. * @returns the new root url
  47751. */
  47752. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  47753. }
  47754. /**
  47755. * Interface used to define a SceneLoader plugin
  47756. */
  47757. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  47758. /**
  47759. * Import meshes into a scene.
  47760. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47761. * @param scene The scene to import into
  47762. * @param data The data to import
  47763. * @param rootUrl The root url for scene and resources
  47764. * @param meshes The meshes array to import into
  47765. * @param particleSystems The particle systems array to import into
  47766. * @param skeletons The skeletons array to import into
  47767. * @param onError The callback when import fails
  47768. * @returns True if successful or false otherwise
  47769. */
  47770. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  47771. /**
  47772. * Load into a scene.
  47773. * @param scene The scene to load into
  47774. * @param data The data to import
  47775. * @param rootUrl The root url for scene and resources
  47776. * @param onError The callback when import fails
  47777. * @returns True if successful or false otherwise
  47778. */
  47779. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  47780. /**
  47781. * Load into an asset container.
  47782. * @param scene The scene to load into
  47783. * @param data The data to import
  47784. * @param rootUrl The root url for scene and resources
  47785. * @param onError The callback when import fails
  47786. * @returns The loaded asset container
  47787. */
  47788. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  47789. }
  47790. /**
  47791. * Interface used to define an async SceneLoader plugin
  47792. */
  47793. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  47794. /**
  47795. * Import meshes into a scene.
  47796. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47797. * @param scene The scene to import into
  47798. * @param data The data to import
  47799. * @param rootUrl The root url for scene and resources
  47800. * @param onProgress The callback when the load progresses
  47801. * @param fileName Defines the name of the file to load
  47802. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  47803. */
  47804. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  47805. meshes: AbstractMesh[];
  47806. particleSystems: IParticleSystem[];
  47807. skeletons: Skeleton[];
  47808. animationGroups: AnimationGroup[];
  47809. }>;
  47810. /**
  47811. * Load into a scene.
  47812. * @param scene The scene to load into
  47813. * @param data The data to import
  47814. * @param rootUrl The root url for scene and resources
  47815. * @param onProgress The callback when the load progresses
  47816. * @param fileName Defines the name of the file to load
  47817. * @returns Nothing
  47818. */
  47819. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  47820. /**
  47821. * Load into an asset container.
  47822. * @param scene The scene to load into
  47823. * @param data The data to import
  47824. * @param rootUrl The root url for scene and resources
  47825. * @param onProgress The callback when the load progresses
  47826. * @param fileName Defines the name of the file to load
  47827. * @returns The loaded asset container
  47828. */
  47829. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  47830. }
  47831. /**
  47832. * Mode that determines how to handle old animation groups before loading new ones.
  47833. */
  47834. export enum SceneLoaderAnimationGroupLoadingMode {
  47835. /**
  47836. * Reset all old animations to initial state then dispose them.
  47837. */
  47838. Clean = 0,
  47839. /**
  47840. * Stop all old animations.
  47841. */
  47842. Stop = 1,
  47843. /**
  47844. * Restart old animations from first frame.
  47845. */
  47846. Sync = 2,
  47847. /**
  47848. * Old animations remains untouched.
  47849. */
  47850. NoSync = 3
  47851. }
  47852. /**
  47853. * Defines a plugin registered by the SceneLoader
  47854. */
  47855. interface IRegisteredPlugin {
  47856. /**
  47857. * Defines the plugin to use
  47858. */
  47859. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  47860. /**
  47861. * Defines if the plugin supports binary data
  47862. */
  47863. isBinary: boolean;
  47864. }
  47865. /**
  47866. * Class used to load scene from various file formats using registered plugins
  47867. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  47868. */
  47869. export class SceneLoader {
  47870. /**
  47871. * No logging while loading
  47872. */
  47873. static readonly NO_LOGGING: number;
  47874. /**
  47875. * Minimal logging while loading
  47876. */
  47877. static readonly MINIMAL_LOGGING: number;
  47878. /**
  47879. * Summary logging while loading
  47880. */
  47881. static readonly SUMMARY_LOGGING: number;
  47882. /**
  47883. * Detailled logging while loading
  47884. */
  47885. static readonly DETAILED_LOGGING: number;
  47886. /**
  47887. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  47888. */
  47889. static get ForceFullSceneLoadingForIncremental(): boolean;
  47890. static set ForceFullSceneLoadingForIncremental(value: boolean);
  47891. /**
  47892. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  47893. */
  47894. static get ShowLoadingScreen(): boolean;
  47895. static set ShowLoadingScreen(value: boolean);
  47896. /**
  47897. * Defines the current logging level (while loading the scene)
  47898. * @ignorenaming
  47899. */
  47900. static get loggingLevel(): number;
  47901. static set loggingLevel(value: number);
  47902. /**
  47903. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  47904. */
  47905. static get CleanBoneMatrixWeights(): boolean;
  47906. static set CleanBoneMatrixWeights(value: boolean);
  47907. /**
  47908. * Event raised when a plugin is used to load a scene
  47909. */
  47910. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  47911. private static _registeredPlugins;
  47912. private static _showingLoadingScreen;
  47913. /**
  47914. * Gets the default plugin (used to load Babylon files)
  47915. * @returns the .babylon plugin
  47916. */
  47917. static GetDefaultPlugin(): IRegisteredPlugin;
  47918. private static _GetPluginForExtension;
  47919. private static _GetPluginForDirectLoad;
  47920. private static _GetPluginForFilename;
  47921. private static _GetDirectLoad;
  47922. private static _LoadData;
  47923. private static _GetFileInfo;
  47924. /**
  47925. * Gets a plugin that can load the given extension
  47926. * @param extension defines the extension to load
  47927. * @returns a plugin or null if none works
  47928. */
  47929. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  47930. /**
  47931. * Gets a boolean indicating that the given extension can be loaded
  47932. * @param extension defines the extension to load
  47933. * @returns true if the extension is supported
  47934. */
  47935. static IsPluginForExtensionAvailable(extension: string): boolean;
  47936. /**
  47937. * Adds a new plugin to the list of registered plugins
  47938. * @param plugin defines the plugin to add
  47939. */
  47940. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  47941. /**
  47942. * Import meshes into a scene
  47943. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47944. * @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)
  47945. * @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)
  47946. * @param scene the instance of BABYLON.Scene to append to
  47947. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  47948. * @param onProgress a callback with a progress event for each file being loaded
  47949. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47950. * @param pluginExtension the extension used to determine the plugin
  47951. * @returns The loaded plugin
  47952. */
  47953. 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>;
  47954. /**
  47955. * Import meshes into a scene
  47956. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47957. * @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)
  47958. * @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)
  47959. * @param scene the instance of BABYLON.Scene to append to
  47960. * @param onProgress a callback with a progress event for each file being loaded
  47961. * @param pluginExtension the extension used to determine the plugin
  47962. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  47963. */
  47964. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  47965. meshes: AbstractMesh[];
  47966. particleSystems: IParticleSystem[];
  47967. skeletons: Skeleton[];
  47968. animationGroups: AnimationGroup[];
  47969. }>;
  47970. /**
  47971. * Load a scene
  47972. * @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)
  47973. * @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)
  47974. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47975. * @param onSuccess a callback with the scene when import succeeds
  47976. * @param onProgress a callback with a progress event for each file being loaded
  47977. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47978. * @param pluginExtension the extension used to determine the plugin
  47979. * @returns The loaded plugin
  47980. */
  47981. 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>;
  47982. /**
  47983. * Load a scene
  47984. * @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)
  47985. * @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)
  47986. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47987. * @param onProgress a callback with a progress event for each file being loaded
  47988. * @param pluginExtension the extension used to determine the plugin
  47989. * @returns The loaded scene
  47990. */
  47991. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  47992. /**
  47993. * Append a scene
  47994. * @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)
  47995. * @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)
  47996. * @param scene is the instance of BABYLON.Scene to append to
  47997. * @param onSuccess a callback with the scene when import succeeds
  47998. * @param onProgress a callback with a progress event for each file being loaded
  47999. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48000. * @param pluginExtension the extension used to determine the plugin
  48001. * @returns The loaded plugin
  48002. */
  48003. 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>;
  48004. /**
  48005. * Append a scene
  48006. * @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)
  48007. * @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)
  48008. * @param scene is the instance of BABYLON.Scene to append to
  48009. * @param onProgress a callback with a progress event for each file being loaded
  48010. * @param pluginExtension the extension used to determine the plugin
  48011. * @returns The given scene
  48012. */
  48013. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  48014. /**
  48015. * Load a scene into an asset container
  48016. * @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)
  48017. * @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)
  48018. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48019. * @param onSuccess a callback with the scene when import succeeds
  48020. * @param onProgress a callback with a progress event for each file being loaded
  48021. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48022. * @param pluginExtension the extension used to determine the plugin
  48023. * @returns The loaded plugin
  48024. */
  48025. 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>;
  48026. /**
  48027. * Load a scene into an asset container
  48028. * @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)
  48029. * @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)
  48030. * @param scene is the instance of Scene to append to
  48031. * @param onProgress a callback with a progress event for each file being loaded
  48032. * @param pluginExtension the extension used to determine the plugin
  48033. * @returns The loaded asset container
  48034. */
  48035. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  48036. /**
  48037. * Import animations from a file into a scene
  48038. * @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)
  48039. * @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)
  48040. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48041. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48042. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48043. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48044. * @param onSuccess a callback with the scene when import succeeds
  48045. * @param onProgress a callback with a progress event for each file being loaded
  48046. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48047. * @param pluginExtension the extension used to determine the plugin
  48048. */
  48049. 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;
  48050. /**
  48051. * Import animations from a file into a scene
  48052. * @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)
  48053. * @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)
  48054. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48055. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48056. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48057. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48058. * @param onSuccess a callback with the scene when import succeeds
  48059. * @param onProgress a callback with a progress event for each file being loaded
  48060. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48061. * @param pluginExtension the extension used to determine the plugin
  48062. * @returns the updated scene with imported animations
  48063. */
  48064. 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>;
  48065. }
  48066. }
  48067. declare module BABYLON {
  48068. /**
  48069. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  48070. */
  48071. export type MotionControllerHandedness = "none" | "left" | "right";
  48072. /**
  48073. * The type of components available in motion controllers.
  48074. * This is not the name of the component.
  48075. */
  48076. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  48077. /**
  48078. * The state of a controller component
  48079. */
  48080. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  48081. /**
  48082. * The schema of motion controller layout.
  48083. * No object will be initialized using this interface
  48084. * This is used just to define the profile.
  48085. */
  48086. export interface IMotionControllerLayout {
  48087. /**
  48088. * Path to load the assets. Usually relative to the base path
  48089. */
  48090. assetPath: string;
  48091. /**
  48092. * Available components (unsorted)
  48093. */
  48094. components: {
  48095. /**
  48096. * A map of component Ids
  48097. */
  48098. [componentId: string]: {
  48099. /**
  48100. * The type of input the component outputs
  48101. */
  48102. type: MotionControllerComponentType;
  48103. /**
  48104. * The indices of this component in the gamepad object
  48105. */
  48106. gamepadIndices: {
  48107. /**
  48108. * Index of button
  48109. */
  48110. button?: number;
  48111. /**
  48112. * If available, index of x-axis
  48113. */
  48114. xAxis?: number;
  48115. /**
  48116. * If available, index of y-axis
  48117. */
  48118. yAxis?: number;
  48119. };
  48120. /**
  48121. * The mesh's root node name
  48122. */
  48123. rootNodeName: string;
  48124. /**
  48125. * Animation definitions for this model
  48126. */
  48127. visualResponses: {
  48128. [stateKey: string]: {
  48129. /**
  48130. * What property will be animated
  48131. */
  48132. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  48133. /**
  48134. * What states influence this visual response
  48135. */
  48136. states: MotionControllerComponentStateType[];
  48137. /**
  48138. * Type of animation - movement or visibility
  48139. */
  48140. valueNodeProperty: "transform" | "visibility";
  48141. /**
  48142. * Base node name to move. Its position will be calculated according to the min and max nodes
  48143. */
  48144. valueNodeName?: string;
  48145. /**
  48146. * Minimum movement node
  48147. */
  48148. minNodeName?: string;
  48149. /**
  48150. * Max movement node
  48151. */
  48152. maxNodeName?: string;
  48153. };
  48154. };
  48155. /**
  48156. * If touch enabled, what is the name of node to display user feedback
  48157. */
  48158. touchPointNodeName?: string;
  48159. };
  48160. };
  48161. /**
  48162. * Is it xr standard mapping or not
  48163. */
  48164. gamepadMapping: "" | "xr-standard";
  48165. /**
  48166. * Base root node of this entire model
  48167. */
  48168. rootNodeName: string;
  48169. /**
  48170. * Defines the main button component id
  48171. */
  48172. selectComponentId: string;
  48173. }
  48174. /**
  48175. * A definition for the layout map in the input profile
  48176. */
  48177. export interface IMotionControllerLayoutMap {
  48178. /**
  48179. * Layouts with handedness type as a key
  48180. */
  48181. [handedness: string]: IMotionControllerLayout;
  48182. }
  48183. /**
  48184. * The XR Input profile schema
  48185. * Profiles can be found here:
  48186. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  48187. */
  48188. export interface IMotionControllerProfile {
  48189. /**
  48190. * fallback profiles for this profileId
  48191. */
  48192. fallbackProfileIds: string[];
  48193. /**
  48194. * The layout map, with handedness as key
  48195. */
  48196. layouts: IMotionControllerLayoutMap;
  48197. /**
  48198. * The id of this profile
  48199. * correlates to the profile(s) in the xrInput.profiles array
  48200. */
  48201. profileId: string;
  48202. }
  48203. /**
  48204. * A helper-interface for the 3 meshes needed for controller button animation
  48205. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  48206. */
  48207. export interface IMotionControllerButtonMeshMap {
  48208. /**
  48209. * the mesh that defines the pressed value mesh position.
  48210. * This is used to find the max-position of this button
  48211. */
  48212. pressedMesh: AbstractMesh;
  48213. /**
  48214. * the mesh that defines the unpressed value mesh position.
  48215. * This is used to find the min (or initial) position of this button
  48216. */
  48217. unpressedMesh: AbstractMesh;
  48218. /**
  48219. * The mesh that will be changed when value changes
  48220. */
  48221. valueMesh: AbstractMesh;
  48222. }
  48223. /**
  48224. * A helper-interface for the 3 meshes needed for controller axis animation.
  48225. * This will be expanded when touchpad animations are fully supported
  48226. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  48227. */
  48228. export interface IMotionControllerMeshMap {
  48229. /**
  48230. * the mesh that defines the maximum value mesh position.
  48231. */
  48232. maxMesh?: AbstractMesh;
  48233. /**
  48234. * the mesh that defines the minimum value mesh position.
  48235. */
  48236. minMesh?: AbstractMesh;
  48237. /**
  48238. * The mesh that will be changed when axis value changes
  48239. */
  48240. valueMesh?: AbstractMesh;
  48241. }
  48242. /**
  48243. * The elements needed for change-detection of the gamepad objects in motion controllers
  48244. */
  48245. export interface IMinimalMotionControllerObject {
  48246. /**
  48247. * Available axes of this controller
  48248. */
  48249. axes: number[];
  48250. /**
  48251. * An array of available buttons
  48252. */
  48253. buttons: Array<{
  48254. /**
  48255. * Value of the button/trigger
  48256. */
  48257. value: number;
  48258. /**
  48259. * If the button/trigger is currently touched
  48260. */
  48261. touched: boolean;
  48262. /**
  48263. * If the button/trigger is currently pressed
  48264. */
  48265. pressed: boolean;
  48266. }>;
  48267. /**
  48268. * EXPERIMENTAL haptic support.
  48269. */
  48270. hapticActuators?: Array<{
  48271. pulse: (value: number, duration: number) => Promise<boolean>;
  48272. }>;
  48273. }
  48274. /**
  48275. * An Abstract Motion controller
  48276. * This class receives an xrInput and a profile layout and uses those to initialize the components
  48277. * Each component has an observable to check for changes in value and state
  48278. */
  48279. export abstract class WebXRAbstractMotionController implements IDisposable {
  48280. protected scene: Scene;
  48281. protected layout: IMotionControllerLayout;
  48282. /**
  48283. * The gamepad object correlating to this controller
  48284. */
  48285. gamepadObject: IMinimalMotionControllerObject;
  48286. /**
  48287. * handedness (left/right/none) of this controller
  48288. */
  48289. handedness: MotionControllerHandedness;
  48290. private _initComponent;
  48291. private _modelReady;
  48292. /**
  48293. * A map of components (WebXRControllerComponent) in this motion controller
  48294. * Components have a ComponentType and can also have both button and axis definitions
  48295. */
  48296. readonly components: {
  48297. [id: string]: WebXRControllerComponent;
  48298. };
  48299. /**
  48300. * Disable the model's animation. Can be set at any time.
  48301. */
  48302. disableAnimation: boolean;
  48303. /**
  48304. * Observers registered here will be triggered when the model of this controller is done loading
  48305. */
  48306. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  48307. /**
  48308. * The profile id of this motion controller
  48309. */
  48310. abstract profileId: string;
  48311. /**
  48312. * The root mesh of the model. It is null if the model was not yet initialized
  48313. */
  48314. rootMesh: Nullable<AbstractMesh>;
  48315. /**
  48316. * constructs a new abstract motion controller
  48317. * @param scene the scene to which the model of the controller will be added
  48318. * @param layout The profile layout to load
  48319. * @param gamepadObject The gamepad object correlating to this controller
  48320. * @param handedness handedness (left/right/none) of this controller
  48321. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  48322. */
  48323. constructor(scene: Scene, layout: IMotionControllerLayout,
  48324. /**
  48325. * The gamepad object correlating to this controller
  48326. */
  48327. gamepadObject: IMinimalMotionControllerObject,
  48328. /**
  48329. * handedness (left/right/none) of this controller
  48330. */
  48331. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  48332. /**
  48333. * Dispose this controller, the model mesh and all its components
  48334. */
  48335. dispose(): void;
  48336. /**
  48337. * Returns all components of specific type
  48338. * @param type the type to search for
  48339. * @return an array of components with this type
  48340. */
  48341. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  48342. /**
  48343. * get a component based an its component id as defined in layout.components
  48344. * @param id the id of the component
  48345. * @returns the component correlates to the id or undefined if not found
  48346. */
  48347. getComponent(id: string): WebXRControllerComponent;
  48348. /**
  48349. * Get the list of components available in this motion controller
  48350. * @returns an array of strings correlating to available components
  48351. */
  48352. getComponentIds(): string[];
  48353. /**
  48354. * Get the first component of specific type
  48355. * @param type type of component to find
  48356. * @return a controller component or null if not found
  48357. */
  48358. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  48359. /**
  48360. * Get the main (Select) component of this controller as defined in the layout
  48361. * @returns the main component of this controller
  48362. */
  48363. getMainComponent(): WebXRControllerComponent;
  48364. /**
  48365. * Loads the model correlating to this controller
  48366. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  48367. * @returns A promise fulfilled with the result of the model loading
  48368. */
  48369. loadModel(): Promise<boolean>;
  48370. /**
  48371. * Update this model using the current XRFrame
  48372. * @param xrFrame the current xr frame to use and update the model
  48373. */
  48374. updateFromXRFrame(xrFrame: XRFrame): void;
  48375. /**
  48376. * Backwards compatibility due to a deeply-integrated typo
  48377. */
  48378. get handness(): XREye;
  48379. /**
  48380. * Pulse (vibrate) this controller
  48381. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  48382. * Consecutive calls to this function will cancel the last pulse call
  48383. *
  48384. * @param value the strength of the pulse in 0.0...1.0 range
  48385. * @param duration Duration of the pulse in milliseconds
  48386. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  48387. * @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
  48388. */
  48389. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  48390. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  48391. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  48392. /**
  48393. * Moves the axis on the controller mesh based on its current state
  48394. * @param axis the index of the axis
  48395. * @param axisValue the value of the axis which determines the meshes new position
  48396. * @hidden
  48397. */
  48398. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  48399. /**
  48400. * Update the model itself with the current frame data
  48401. * @param xrFrame the frame to use for updating the model mesh
  48402. */
  48403. protected updateModel(xrFrame: XRFrame): void;
  48404. /**
  48405. * Get the filename and path for this controller's model
  48406. * @returns a map of filename and path
  48407. */
  48408. protected abstract _getFilenameAndPath(): {
  48409. filename: string;
  48410. path: string;
  48411. };
  48412. /**
  48413. * This function is called before the mesh is loaded. It checks for loading constraints.
  48414. * For example, this function can check if the GLB loader is available
  48415. * If this function returns false, the generic controller will be loaded instead
  48416. * @returns Is the client ready to load the mesh
  48417. */
  48418. protected abstract _getModelLoadingConstraints(): boolean;
  48419. /**
  48420. * This function will be called after the model was successfully loaded and can be used
  48421. * for mesh transformations before it is available for the user
  48422. * @param meshes the loaded meshes
  48423. */
  48424. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  48425. /**
  48426. * Set the root mesh for this controller. Important for the WebXR controller class
  48427. * @param meshes the loaded meshes
  48428. */
  48429. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  48430. /**
  48431. * A function executed each frame that updates the mesh (if needed)
  48432. * @param xrFrame the current xrFrame
  48433. */
  48434. protected abstract _updateModel(xrFrame: XRFrame): void;
  48435. private _getGenericFilenameAndPath;
  48436. private _getGenericParentMesh;
  48437. }
  48438. }
  48439. declare module BABYLON {
  48440. /**
  48441. * A generic trigger-only motion controller for WebXR
  48442. */
  48443. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  48444. /**
  48445. * Static version of the profile id of this controller
  48446. */
  48447. static ProfileId: string;
  48448. profileId: string;
  48449. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  48450. protected _getFilenameAndPath(): {
  48451. filename: string;
  48452. path: string;
  48453. };
  48454. protected _getModelLoadingConstraints(): boolean;
  48455. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  48456. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48457. protected _updateModel(): void;
  48458. }
  48459. }
  48460. declare module BABYLON {
  48461. /**
  48462. * Class containing static functions to help procedurally build meshes
  48463. */
  48464. export class SphereBuilder {
  48465. /**
  48466. * Creates a sphere mesh
  48467. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  48468. * * 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`)
  48469. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  48470. * * 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
  48471. * * 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)
  48472. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48473. * * 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
  48474. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48475. * @param name defines the name of the mesh
  48476. * @param options defines the options used to create the mesh
  48477. * @param scene defines the hosting scene
  48478. * @returns the sphere mesh
  48479. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  48480. */
  48481. static CreateSphere(name: string, options: {
  48482. segments?: number;
  48483. diameter?: number;
  48484. diameterX?: number;
  48485. diameterY?: number;
  48486. diameterZ?: number;
  48487. arc?: number;
  48488. slice?: number;
  48489. sideOrientation?: number;
  48490. frontUVs?: Vector4;
  48491. backUVs?: Vector4;
  48492. updatable?: boolean;
  48493. }, scene?: Nullable<Scene>): Mesh;
  48494. }
  48495. }
  48496. declare module BABYLON {
  48497. /**
  48498. * A profiled motion controller has its profile loaded from an online repository.
  48499. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  48500. */
  48501. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  48502. private _repositoryUrl;
  48503. private _buttonMeshMapping;
  48504. private _touchDots;
  48505. /**
  48506. * The profile ID of this controller. Will be populated when the controller initializes.
  48507. */
  48508. profileId: string;
  48509. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  48510. dispose(): void;
  48511. protected _getFilenameAndPath(): {
  48512. filename: string;
  48513. path: string;
  48514. };
  48515. protected _getModelLoadingConstraints(): boolean;
  48516. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  48517. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48518. protected _updateModel(_xrFrame: XRFrame): void;
  48519. }
  48520. }
  48521. declare module BABYLON {
  48522. /**
  48523. * A construction function type to create a new controller based on an xrInput object
  48524. */
  48525. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  48526. /**
  48527. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  48528. *
  48529. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  48530. * it should be replaced with auto-loaded controllers.
  48531. *
  48532. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  48533. */
  48534. export class WebXRMotionControllerManager {
  48535. private static _AvailableControllers;
  48536. private static _Fallbacks;
  48537. private static _ProfileLoadingPromises;
  48538. private static _ProfilesList;
  48539. /**
  48540. * The base URL of the online controller repository. Can be changed at any time.
  48541. */
  48542. static BaseRepositoryUrl: string;
  48543. /**
  48544. * Which repository gets priority - local or online
  48545. */
  48546. static PrioritizeOnlineRepository: boolean;
  48547. /**
  48548. * Use the online repository, or use only locally-defined controllers
  48549. */
  48550. static UseOnlineRepository: boolean;
  48551. /**
  48552. * Clear the cache used for profile loading and reload when requested again
  48553. */
  48554. static ClearProfilesCache(): void;
  48555. /**
  48556. * Register the default fallbacks.
  48557. * This function is called automatically when this file is imported.
  48558. */
  48559. static DefaultFallbacks(): void;
  48560. /**
  48561. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  48562. * @param profileId the profile to which a fallback needs to be found
  48563. * @return an array with corresponding fallback profiles
  48564. */
  48565. static FindFallbackWithProfileId(profileId: string): string[];
  48566. /**
  48567. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  48568. * The order of search:
  48569. *
  48570. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  48571. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  48572. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  48573. * 4) return the generic trigger controller if none were found
  48574. *
  48575. * @param xrInput the xrInput to which a new controller is initialized
  48576. * @param scene the scene to which the model will be added
  48577. * @param forceProfile force a certain profile for this controller
  48578. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  48579. */
  48580. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  48581. /**
  48582. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  48583. *
  48584. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  48585. *
  48586. * @param type the profile type to register
  48587. * @param constructFunction the function to be called when loading this profile
  48588. */
  48589. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  48590. /**
  48591. * Register a fallback to a specific profile.
  48592. * @param profileId the profileId that will receive the fallbacks
  48593. * @param fallbacks A list of fallback profiles
  48594. */
  48595. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  48596. /**
  48597. * Will update the list of profiles available in the repository
  48598. * @return a promise that resolves to a map of profiles available online
  48599. */
  48600. static UpdateProfilesList(): Promise<{
  48601. [profile: string]: string;
  48602. }>;
  48603. private static _LoadProfileFromRepository;
  48604. private static _LoadProfilesFromAvailableControllers;
  48605. }
  48606. }
  48607. declare module BABYLON {
  48608. /**
  48609. * Configuration options for the WebXR controller creation
  48610. */
  48611. export interface IWebXRControllerOptions {
  48612. /**
  48613. * Should the controller mesh be animated when a user interacts with it
  48614. * The pressed buttons / thumbstick and touchpad animations will be disabled
  48615. */
  48616. disableMotionControllerAnimation?: boolean;
  48617. /**
  48618. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  48619. */
  48620. doNotLoadControllerMesh?: boolean;
  48621. /**
  48622. * Force a specific controller type for this controller.
  48623. * This can be used when creating your own profile or when testing different controllers
  48624. */
  48625. forceControllerProfile?: string;
  48626. /**
  48627. * Defines a rendering group ID for meshes that will be loaded.
  48628. * This is for the default controllers only.
  48629. */
  48630. renderingGroupId?: number;
  48631. }
  48632. /**
  48633. * Represents an XR controller
  48634. */
  48635. export class WebXRInputSource {
  48636. private _scene;
  48637. /** The underlying input source for the controller */
  48638. inputSource: XRInputSource;
  48639. private _options;
  48640. private _tmpVector;
  48641. private _uniqueId;
  48642. private _disposed;
  48643. /**
  48644. * 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
  48645. */
  48646. grip?: AbstractMesh;
  48647. /**
  48648. * If available, this is the gamepad object related to this controller.
  48649. * Using this object it is possible to get click events and trackpad changes of the
  48650. * webxr controller that is currently being used.
  48651. */
  48652. motionController?: WebXRAbstractMotionController;
  48653. /**
  48654. * Event that fires when the controller is removed/disposed.
  48655. * The object provided as event data is this controller, after associated assets were disposed.
  48656. * uniqueId is still available.
  48657. */
  48658. onDisposeObservable: Observable<WebXRInputSource>;
  48659. /**
  48660. * Will be triggered when the mesh associated with the motion controller is done loading.
  48661. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  48662. * A shortened version of controller -> motion controller -> on mesh loaded.
  48663. */
  48664. onMeshLoadedObservable: Observable<AbstractMesh>;
  48665. /**
  48666. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  48667. */
  48668. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  48669. /**
  48670. * Pointer which can be used to select objects or attach a visible laser to
  48671. */
  48672. pointer: AbstractMesh;
  48673. /**
  48674. * Creates the input source object
  48675. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  48676. * @param _scene the scene which the controller should be associated to
  48677. * @param inputSource the underlying input source for the controller
  48678. * @param _options options for this controller creation
  48679. */
  48680. constructor(_scene: Scene,
  48681. /** The underlying input source for the controller */
  48682. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  48683. /**
  48684. * Get this controllers unique id
  48685. */
  48686. get uniqueId(): string;
  48687. /**
  48688. * Disposes of the object
  48689. */
  48690. dispose(): void;
  48691. /**
  48692. * Gets a world space ray coming from the pointer or grip
  48693. * @param result the resulting ray
  48694. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  48695. */
  48696. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  48697. /**
  48698. * Updates the controller pose based on the given XRFrame
  48699. * @param xrFrame xr frame to update the pose with
  48700. * @param referenceSpace reference space to use
  48701. */
  48702. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  48703. }
  48704. }
  48705. declare module BABYLON {
  48706. /**
  48707. * The schema for initialization options of the XR Input class
  48708. */
  48709. export interface IWebXRInputOptions {
  48710. /**
  48711. * If set to true no model will be automatically loaded
  48712. */
  48713. doNotLoadControllerMeshes?: boolean;
  48714. /**
  48715. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  48716. * If not found, the xr input profile data will be used.
  48717. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  48718. */
  48719. forceInputProfile?: string;
  48720. /**
  48721. * Do not send a request to the controller repository to load the profile.
  48722. *
  48723. * Instead, use the controllers available in babylon itself.
  48724. */
  48725. disableOnlineControllerRepository?: boolean;
  48726. /**
  48727. * A custom URL for the controllers repository
  48728. */
  48729. customControllersRepositoryURL?: string;
  48730. /**
  48731. * Should the controller model's components not move according to the user input
  48732. */
  48733. disableControllerAnimation?: boolean;
  48734. /**
  48735. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  48736. */
  48737. controllerOptions?: IWebXRControllerOptions;
  48738. }
  48739. /**
  48740. * XR input used to track XR inputs such as controllers/rays
  48741. */
  48742. export class WebXRInput implements IDisposable {
  48743. /**
  48744. * the xr session manager for this session
  48745. */
  48746. xrSessionManager: WebXRSessionManager;
  48747. /**
  48748. * the WebXR camera for this session. Mainly used for teleportation
  48749. */
  48750. xrCamera: WebXRCamera;
  48751. private readonly options;
  48752. /**
  48753. * XR controllers being tracked
  48754. */
  48755. controllers: Array<WebXRInputSource>;
  48756. private _frameObserver;
  48757. private _sessionEndedObserver;
  48758. private _sessionInitObserver;
  48759. /**
  48760. * Event when a controller has been connected/added
  48761. */
  48762. onControllerAddedObservable: Observable<WebXRInputSource>;
  48763. /**
  48764. * Event when a controller has been removed/disconnected
  48765. */
  48766. onControllerRemovedObservable: Observable<WebXRInputSource>;
  48767. /**
  48768. * Initializes the WebXRInput
  48769. * @param xrSessionManager the xr session manager for this session
  48770. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  48771. * @param options = initialization options for this xr input
  48772. */
  48773. constructor(
  48774. /**
  48775. * the xr session manager for this session
  48776. */
  48777. xrSessionManager: WebXRSessionManager,
  48778. /**
  48779. * the WebXR camera for this session. Mainly used for teleportation
  48780. */
  48781. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  48782. private _onInputSourcesChange;
  48783. private _addAndRemoveControllers;
  48784. /**
  48785. * Disposes of the object
  48786. */
  48787. dispose(): void;
  48788. }
  48789. }
  48790. declare module BABYLON {
  48791. /**
  48792. * This is the base class for all WebXR features.
  48793. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  48794. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  48795. */
  48796. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  48797. protected _xrSessionManager: WebXRSessionManager;
  48798. private _attached;
  48799. private _removeOnDetach;
  48800. /**
  48801. * Is this feature disposed?
  48802. */
  48803. isDisposed: boolean;
  48804. /**
  48805. * Should auto-attach be disabled?
  48806. */
  48807. disableAutoAttach: boolean;
  48808. /**
  48809. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  48810. */
  48811. xrNativeFeatureName: string;
  48812. /**
  48813. * Construct a new (abstract) WebXR feature
  48814. * @param _xrSessionManager the xr session manager for this feature
  48815. */
  48816. constructor(_xrSessionManager: WebXRSessionManager);
  48817. /**
  48818. * Is this feature attached
  48819. */
  48820. get attached(): boolean;
  48821. /**
  48822. * attach this feature
  48823. *
  48824. * @param force should attachment be forced (even when already attached)
  48825. * @returns true if successful, false is failed or already attached
  48826. */
  48827. attach(force?: boolean): boolean;
  48828. /**
  48829. * detach this feature.
  48830. *
  48831. * @returns true if successful, false if failed or already detached
  48832. */
  48833. detach(): boolean;
  48834. /**
  48835. * Dispose this feature and all of the resources attached
  48836. */
  48837. dispose(): void;
  48838. /**
  48839. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  48840. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  48841. *
  48842. * @returns whether or not the feature is compatible in this environment
  48843. */
  48844. isCompatible(): boolean;
  48845. /**
  48846. * This is used to register callbacks that will automatically be removed when detach is called.
  48847. * @param observable the observable to which the observer will be attached
  48848. * @param callback the callback to register
  48849. */
  48850. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  48851. /**
  48852. * Code in this function will be executed on each xrFrame received from the browser.
  48853. * This function will not execute after the feature is detached.
  48854. * @param _xrFrame the current frame
  48855. */
  48856. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  48857. }
  48858. }
  48859. declare module BABYLON {
  48860. /**
  48861. * Renders a layer on top of an existing scene
  48862. */
  48863. export class UtilityLayerRenderer implements IDisposable {
  48864. /** the original scene that will be rendered on top of */
  48865. originalScene: Scene;
  48866. private _pointerCaptures;
  48867. private _lastPointerEvents;
  48868. private static _DefaultUtilityLayer;
  48869. private static _DefaultKeepDepthUtilityLayer;
  48870. private _sharedGizmoLight;
  48871. private _renderCamera;
  48872. /**
  48873. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  48874. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  48875. * @returns the camera that is used when rendering the utility layer
  48876. */
  48877. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  48878. /**
  48879. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  48880. * @param cam the camera that should be used when rendering the utility layer
  48881. */
  48882. setRenderCamera(cam: Nullable<Camera>): void;
  48883. /**
  48884. * @hidden
  48885. * Light which used by gizmos to get light shading
  48886. */
  48887. _getSharedGizmoLight(): HemisphericLight;
  48888. /**
  48889. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  48890. */
  48891. pickUtilitySceneFirst: boolean;
  48892. /**
  48893. * 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)
  48894. */
  48895. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  48896. /**
  48897. * 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)
  48898. */
  48899. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  48900. /**
  48901. * The scene that is rendered on top of the original scene
  48902. */
  48903. utilityLayerScene: Scene;
  48904. /**
  48905. * If the utility layer should automatically be rendered on top of existing scene
  48906. */
  48907. shouldRender: boolean;
  48908. /**
  48909. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  48910. */
  48911. onlyCheckPointerDownEvents: boolean;
  48912. /**
  48913. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  48914. */
  48915. processAllEvents: boolean;
  48916. /**
  48917. * Observable raised when the pointer move from the utility layer scene to the main scene
  48918. */
  48919. onPointerOutObservable: Observable<number>;
  48920. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  48921. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  48922. private _afterRenderObserver;
  48923. private _sceneDisposeObserver;
  48924. private _originalPointerObserver;
  48925. /**
  48926. * Instantiates a UtilityLayerRenderer
  48927. * @param originalScene the original scene that will be rendered on top of
  48928. * @param handleEvents boolean indicating if the utility layer should handle events
  48929. */
  48930. constructor(
  48931. /** the original scene that will be rendered on top of */
  48932. originalScene: Scene, handleEvents?: boolean);
  48933. private _notifyObservers;
  48934. /**
  48935. * Renders the utility layers scene on top of the original scene
  48936. */
  48937. render(): void;
  48938. /**
  48939. * Disposes of the renderer
  48940. */
  48941. dispose(): void;
  48942. private _updateCamera;
  48943. }
  48944. }
  48945. declare module BABYLON {
  48946. /**
  48947. * Options interface for the pointer selection module
  48948. */
  48949. export interface IWebXRControllerPointerSelectionOptions {
  48950. /**
  48951. * if provided, this scene will be used to render meshes.
  48952. */
  48953. customUtilityLayerScene?: Scene;
  48954. /**
  48955. * 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)
  48956. * If not disabled, the last picked point will be used to execute a pointer up event
  48957. * If disabled, pointer up event will be triggered right after the pointer down event.
  48958. * Used in screen and gaze target ray mode only
  48959. */
  48960. disablePointerUpOnTouchOut: boolean;
  48961. /**
  48962. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  48963. */
  48964. forceGazeMode: boolean;
  48965. /**
  48966. * 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
  48967. * to start a new countdown to the pointer down event.
  48968. * Defaults to 1.
  48969. */
  48970. gazeModePointerMovedFactor?: number;
  48971. /**
  48972. * Different button type to use instead of the main component
  48973. */
  48974. overrideButtonId?: string;
  48975. /**
  48976. * use this rendering group id for the meshes (optional)
  48977. */
  48978. renderingGroupId?: number;
  48979. /**
  48980. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  48981. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  48982. * 3000 means 3 seconds between pointing at something and selecting it
  48983. */
  48984. timeToSelect?: number;
  48985. /**
  48986. * Should meshes created here be added to a utility layer or the main scene
  48987. */
  48988. useUtilityLayer?: boolean;
  48989. /**
  48990. * Optional WebXR camera to be used for gaze selection
  48991. */
  48992. gazeCamera?: WebXRCamera;
  48993. /**
  48994. * the xr input to use with this pointer selection
  48995. */
  48996. xrInput: WebXRInput;
  48997. }
  48998. /**
  48999. * A module that will enable pointer selection for motion controllers of XR Input Sources
  49000. */
  49001. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  49002. private readonly _options;
  49003. private static _idCounter;
  49004. private _attachController;
  49005. private _controllers;
  49006. private _scene;
  49007. private _tmpVectorForPickCompare;
  49008. /**
  49009. * The module's name
  49010. */
  49011. static readonly Name: string;
  49012. /**
  49013. * The (Babylon) version of this module.
  49014. * This is an integer representing the implementation version.
  49015. * This number does not correspond to the WebXR specs version
  49016. */
  49017. static readonly Version: number;
  49018. /**
  49019. * Disable lighting on the laser pointer (so it will always be visible)
  49020. */
  49021. disablePointerLighting: boolean;
  49022. /**
  49023. * Disable lighting on the selection mesh (so it will always be visible)
  49024. */
  49025. disableSelectionMeshLighting: boolean;
  49026. /**
  49027. * Should the laser pointer be displayed
  49028. */
  49029. displayLaserPointer: boolean;
  49030. /**
  49031. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  49032. */
  49033. displaySelectionMesh: boolean;
  49034. /**
  49035. * This color will be set to the laser pointer when selection is triggered
  49036. */
  49037. laserPointerPickedColor: Color3;
  49038. /**
  49039. * Default color of the laser pointer
  49040. */
  49041. laserPointerDefaultColor: Color3;
  49042. /**
  49043. * default color of the selection ring
  49044. */
  49045. selectionMeshDefaultColor: Color3;
  49046. /**
  49047. * This color will be applied to the selection ring when selection is triggered
  49048. */
  49049. selectionMeshPickedColor: Color3;
  49050. /**
  49051. * Optional filter to be used for ray selection. This predicate shares behavior with
  49052. * scene.pointerMovePredicate which takes priority if it is also assigned.
  49053. */
  49054. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49055. /**
  49056. * constructs a new background remover module
  49057. * @param _xrSessionManager the session manager for this module
  49058. * @param _options read-only options to be used in this module
  49059. */
  49060. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  49061. /**
  49062. * attach this feature
  49063. * Will usually be called by the features manager
  49064. *
  49065. * @returns true if successful.
  49066. */
  49067. attach(): boolean;
  49068. /**
  49069. * detach this feature.
  49070. * Will usually be called by the features manager
  49071. *
  49072. * @returns true if successful.
  49073. */
  49074. detach(): boolean;
  49075. /**
  49076. * Will get the mesh under a specific pointer.
  49077. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  49078. * @param controllerId the controllerId to check
  49079. * @returns The mesh under pointer or null if no mesh is under the pointer
  49080. */
  49081. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  49082. /**
  49083. * Get the xr controller that correlates to the pointer id in the pointer event
  49084. *
  49085. * @param id the pointer id to search for
  49086. * @returns the controller that correlates to this id or null if not found
  49087. */
  49088. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  49089. protected _onXRFrame(_xrFrame: XRFrame): void;
  49090. private _attachGazeMode;
  49091. private _attachScreenRayMode;
  49092. private _attachTrackedPointerRayMode;
  49093. private _convertNormalToDirectionOfRay;
  49094. private _detachController;
  49095. private _generateNewMeshPair;
  49096. private _pickingMoved;
  49097. private _updatePointerDistance;
  49098. /** @hidden */
  49099. get lasterPointerDefaultColor(): Color3;
  49100. }
  49101. }
  49102. declare module BABYLON {
  49103. /**
  49104. * Button which can be used to enter a different mode of XR
  49105. */
  49106. export class WebXREnterExitUIButton {
  49107. /** button element */
  49108. element: HTMLElement;
  49109. /** XR initialization options for the button */
  49110. sessionMode: XRSessionMode;
  49111. /** Reference space type */
  49112. referenceSpaceType: XRReferenceSpaceType;
  49113. /**
  49114. * Creates a WebXREnterExitUIButton
  49115. * @param element button element
  49116. * @param sessionMode XR initialization session mode
  49117. * @param referenceSpaceType the type of reference space to be used
  49118. */
  49119. constructor(
  49120. /** button element */
  49121. element: HTMLElement,
  49122. /** XR initialization options for the button */
  49123. sessionMode: XRSessionMode,
  49124. /** Reference space type */
  49125. referenceSpaceType: XRReferenceSpaceType);
  49126. /**
  49127. * Extendable function which can be used to update the button's visuals when the state changes
  49128. * @param activeButton the current active button in the UI
  49129. */
  49130. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  49131. }
  49132. /**
  49133. * Options to create the webXR UI
  49134. */
  49135. export class WebXREnterExitUIOptions {
  49136. /**
  49137. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  49138. */
  49139. customButtons?: Array<WebXREnterExitUIButton>;
  49140. /**
  49141. * A reference space type to use when creating the default button.
  49142. * Default is local-floor
  49143. */
  49144. referenceSpaceType?: XRReferenceSpaceType;
  49145. /**
  49146. * Context to enter xr with
  49147. */
  49148. renderTarget?: Nullable<WebXRRenderTarget>;
  49149. /**
  49150. * A session mode to use when creating the default button.
  49151. * Default is immersive-vr
  49152. */
  49153. sessionMode?: XRSessionMode;
  49154. /**
  49155. * A list of optional features to init the session with
  49156. */
  49157. optionalFeatures?: string[];
  49158. /**
  49159. * A list of optional features to init the session with
  49160. */
  49161. requiredFeatures?: string[];
  49162. }
  49163. /**
  49164. * UI to allow the user to enter/exit XR mode
  49165. */
  49166. export class WebXREnterExitUI implements IDisposable {
  49167. private scene;
  49168. /** version of the options passed to this UI */
  49169. options: WebXREnterExitUIOptions;
  49170. private _activeButton;
  49171. private _buttons;
  49172. /**
  49173. * The HTML Div Element to which buttons are added.
  49174. */
  49175. readonly overlay: HTMLDivElement;
  49176. /**
  49177. * Fired every time the active button is changed.
  49178. *
  49179. * When xr is entered via a button that launches xr that button will be the callback parameter
  49180. *
  49181. * When exiting xr the callback parameter will be null)
  49182. */
  49183. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  49184. /**
  49185. *
  49186. * @param scene babylon scene object to use
  49187. * @param options (read-only) version of the options passed to this UI
  49188. */
  49189. private constructor();
  49190. /**
  49191. * Creates UI to allow the user to enter/exit XR mode
  49192. * @param scene the scene to add the ui to
  49193. * @param helper the xr experience helper to enter/exit xr with
  49194. * @param options options to configure the UI
  49195. * @returns the created ui
  49196. */
  49197. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  49198. /**
  49199. * Disposes of the XR UI component
  49200. */
  49201. dispose(): void;
  49202. private _updateButtons;
  49203. }
  49204. }
  49205. declare module BABYLON {
  49206. /**
  49207. * Class containing static functions to help procedurally build meshes
  49208. */
  49209. export class LinesBuilder {
  49210. /**
  49211. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49212. * * 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
  49213. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49214. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49215. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49216. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49217. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49218. * * 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
  49219. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49221. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49222. * @param name defines the name of the new line system
  49223. * @param options defines the options used to create the line system
  49224. * @param scene defines the hosting scene
  49225. * @returns a new line system mesh
  49226. */
  49227. static CreateLineSystem(name: string, options: {
  49228. lines: Vector3[][];
  49229. updatable?: boolean;
  49230. instance?: Nullable<LinesMesh>;
  49231. colors?: Nullable<Color4[][]>;
  49232. useVertexAlpha?: boolean;
  49233. }, scene: Nullable<Scene>): LinesMesh;
  49234. /**
  49235. * Creates a line mesh
  49236. * 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
  49237. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49238. * * The parameter `points` is an array successive Vector3
  49239. * * 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
  49240. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49241. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49242. * * When updating an instance, remember that only point positions can change, not the number of points
  49243. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49244. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49245. * @param name defines the name of the new line system
  49246. * @param options defines the options used to create the line system
  49247. * @param scene defines the hosting scene
  49248. * @returns a new line mesh
  49249. */
  49250. static CreateLines(name: string, options: {
  49251. points: Vector3[];
  49252. updatable?: boolean;
  49253. instance?: Nullable<LinesMesh>;
  49254. colors?: Color4[];
  49255. useVertexAlpha?: boolean;
  49256. }, scene?: Nullable<Scene>): LinesMesh;
  49257. /**
  49258. * Creates a dashed line mesh
  49259. * * 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
  49260. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49261. * * The parameter `points` is an array successive Vector3
  49262. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49263. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49264. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49265. * * 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
  49266. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49267. * * When updating an instance, remember that only point positions can change, not the number of points
  49268. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49269. * @param name defines the name of the mesh
  49270. * @param options defines the options used to create the mesh
  49271. * @param scene defines the hosting scene
  49272. * @returns the dashed line mesh
  49273. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49274. */
  49275. static CreateDashedLines(name: string, options: {
  49276. points: Vector3[];
  49277. dashSize?: number;
  49278. gapSize?: number;
  49279. dashNb?: number;
  49280. updatable?: boolean;
  49281. instance?: LinesMesh;
  49282. useVertexAlpha?: boolean;
  49283. }, scene?: Nullable<Scene>): LinesMesh;
  49284. }
  49285. }
  49286. declare module BABYLON {
  49287. /**
  49288. * Construction options for a timer
  49289. */
  49290. export interface ITimerOptions<T> {
  49291. /**
  49292. * Time-to-end
  49293. */
  49294. timeout: number;
  49295. /**
  49296. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  49297. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  49298. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  49299. */
  49300. contextObservable: Observable<T>;
  49301. /**
  49302. * Optional parameters when adding an observer to the observable
  49303. */
  49304. observableParameters?: {
  49305. mask?: number;
  49306. insertFirst?: boolean;
  49307. scope?: any;
  49308. };
  49309. /**
  49310. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  49311. */
  49312. breakCondition?: (data?: ITimerData<T>) => boolean;
  49313. /**
  49314. * Will be triggered when the time condition has met
  49315. */
  49316. onEnded?: (data: ITimerData<any>) => void;
  49317. /**
  49318. * Will be triggered when the break condition has met (prematurely ended)
  49319. */
  49320. onAborted?: (data: ITimerData<any>) => void;
  49321. /**
  49322. * Optional function to execute on each tick (or count)
  49323. */
  49324. onTick?: (data: ITimerData<any>) => void;
  49325. }
  49326. /**
  49327. * An interface defining the data sent by the timer
  49328. */
  49329. export interface ITimerData<T> {
  49330. /**
  49331. * When did it start
  49332. */
  49333. startTime: number;
  49334. /**
  49335. * Time now
  49336. */
  49337. currentTime: number;
  49338. /**
  49339. * Time passed since started
  49340. */
  49341. deltaTime: number;
  49342. /**
  49343. * How much is completed, in [0.0...1.0].
  49344. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  49345. */
  49346. completeRate: number;
  49347. /**
  49348. * What the registered observable sent in the last count
  49349. */
  49350. payload: T;
  49351. }
  49352. /**
  49353. * The current state of the timer
  49354. */
  49355. export enum TimerState {
  49356. /**
  49357. * Timer initialized, not yet started
  49358. */
  49359. INIT = 0,
  49360. /**
  49361. * Timer started and counting
  49362. */
  49363. STARTED = 1,
  49364. /**
  49365. * Timer ended (whether aborted or time reached)
  49366. */
  49367. ENDED = 2
  49368. }
  49369. /**
  49370. * A simple version of the timer. Will take options and start the timer immediately after calling it
  49371. *
  49372. * @param options options with which to initialize this timer
  49373. */
  49374. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  49375. /**
  49376. * An advanced implementation of a timer class
  49377. */
  49378. export class AdvancedTimer<T = any> implements IDisposable {
  49379. /**
  49380. * Will notify each time the timer calculates the remaining time
  49381. */
  49382. onEachCountObservable: Observable<ITimerData<T>>;
  49383. /**
  49384. * Will trigger when the timer was aborted due to the break condition
  49385. */
  49386. onTimerAbortedObservable: Observable<ITimerData<T>>;
  49387. /**
  49388. * Will trigger when the timer ended successfully
  49389. */
  49390. onTimerEndedObservable: Observable<ITimerData<T>>;
  49391. /**
  49392. * Will trigger when the timer state has changed
  49393. */
  49394. onStateChangedObservable: Observable<TimerState>;
  49395. private _observer;
  49396. private _contextObservable;
  49397. private _observableParameters;
  49398. private _startTime;
  49399. private _timer;
  49400. private _state;
  49401. private _breakCondition;
  49402. private _timeToEnd;
  49403. private _breakOnNextTick;
  49404. /**
  49405. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  49406. * @param options construction options for this advanced timer
  49407. */
  49408. constructor(options: ITimerOptions<T>);
  49409. /**
  49410. * set a breaking condition for this timer. Default is to never break during count
  49411. * @param predicate the new break condition. Returns true to break, false otherwise
  49412. */
  49413. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  49414. /**
  49415. * Reset ALL associated observables in this advanced timer
  49416. */
  49417. clearObservables(): void;
  49418. /**
  49419. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  49420. *
  49421. * @param timeToEnd how much time to measure until timer ended
  49422. */
  49423. start(timeToEnd?: number): void;
  49424. /**
  49425. * Will force a stop on the next tick.
  49426. */
  49427. stop(): void;
  49428. /**
  49429. * Dispose this timer, clearing all resources
  49430. */
  49431. dispose(): void;
  49432. private _setState;
  49433. private _tick;
  49434. private _stop;
  49435. }
  49436. }
  49437. declare module BABYLON {
  49438. /**
  49439. * The options container for the teleportation module
  49440. */
  49441. export interface IWebXRTeleportationOptions {
  49442. /**
  49443. * if provided, this scene will be used to render meshes.
  49444. */
  49445. customUtilityLayerScene?: Scene;
  49446. /**
  49447. * Values to configure the default target mesh
  49448. */
  49449. defaultTargetMeshOptions?: {
  49450. /**
  49451. * Fill color of the teleportation area
  49452. */
  49453. teleportationFillColor?: string;
  49454. /**
  49455. * Border color for the teleportation area
  49456. */
  49457. teleportationBorderColor?: string;
  49458. /**
  49459. * Disable the mesh's animation sequence
  49460. */
  49461. disableAnimation?: boolean;
  49462. /**
  49463. * Disable lighting on the material or the ring and arrow
  49464. */
  49465. disableLighting?: boolean;
  49466. /**
  49467. * Override the default material of the torus and arrow
  49468. */
  49469. torusArrowMaterial?: Material;
  49470. };
  49471. /**
  49472. * A list of meshes to use as floor meshes.
  49473. * Meshes can be added and removed after initializing the feature using the
  49474. * addFloorMesh and removeFloorMesh functions
  49475. * If empty, rotation will still work
  49476. */
  49477. floorMeshes?: AbstractMesh[];
  49478. /**
  49479. * use this rendering group id for the meshes (optional)
  49480. */
  49481. renderingGroupId?: number;
  49482. /**
  49483. * Should teleportation move only to snap points
  49484. */
  49485. snapPointsOnly?: boolean;
  49486. /**
  49487. * An array of points to which the teleportation will snap to.
  49488. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  49489. */
  49490. snapPositions?: Vector3[];
  49491. /**
  49492. * How close should the teleportation ray be in order to snap to position.
  49493. * Default to 0.8 units (meters)
  49494. */
  49495. snapToPositionRadius?: number;
  49496. /**
  49497. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  49498. * If you want to support rotation, make sure your mesh has a direction indicator.
  49499. *
  49500. * When left untouched, the default mesh will be initialized.
  49501. */
  49502. teleportationTargetMesh?: AbstractMesh;
  49503. /**
  49504. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  49505. */
  49506. timeToTeleport?: number;
  49507. /**
  49508. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  49509. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  49510. */
  49511. useMainComponentOnly?: boolean;
  49512. /**
  49513. * Should meshes created here be added to a utility layer or the main scene
  49514. */
  49515. useUtilityLayer?: boolean;
  49516. /**
  49517. * Babylon XR Input class for controller
  49518. */
  49519. xrInput: WebXRInput;
  49520. /**
  49521. * Meshes that the teleportation ray cannot go through
  49522. */
  49523. pickBlockerMeshes?: AbstractMesh[];
  49524. }
  49525. /**
  49526. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  49527. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  49528. * the input of the attached controllers.
  49529. */
  49530. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  49531. private _options;
  49532. private _controllers;
  49533. private _currentTeleportationControllerId;
  49534. private _floorMeshes;
  49535. private _quadraticBezierCurve;
  49536. private _selectionFeature;
  49537. private _snapToPositions;
  49538. private _snappedToPoint;
  49539. private _teleportationRingMaterial?;
  49540. private _tmpRay;
  49541. private _tmpVector;
  49542. private _tmpQuaternion;
  49543. /**
  49544. * The module's name
  49545. */
  49546. static readonly Name: string;
  49547. /**
  49548. * The (Babylon) version of this module.
  49549. * This is an integer representing the implementation version.
  49550. * This number does not correspond to the webxr specs version
  49551. */
  49552. static readonly Version: number;
  49553. /**
  49554. * Is movement backwards enabled
  49555. */
  49556. backwardsMovementEnabled: boolean;
  49557. /**
  49558. * Distance to travel when moving backwards
  49559. */
  49560. backwardsTeleportationDistance: number;
  49561. /**
  49562. * The distance from the user to the inspection point in the direction of the controller
  49563. * A higher number will allow the user to move further
  49564. * defaults to 5 (meters, in xr units)
  49565. */
  49566. parabolicCheckRadius: number;
  49567. /**
  49568. * Should the module support parabolic ray on top of direct ray
  49569. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  49570. * Very helpful when moving between floors / different heights
  49571. */
  49572. parabolicRayEnabled: boolean;
  49573. /**
  49574. * How much rotation should be applied when rotating right and left
  49575. */
  49576. rotationAngle: number;
  49577. /**
  49578. * Is rotation enabled when moving forward?
  49579. * Disabling this feature will prevent the user from deciding the direction when teleporting
  49580. */
  49581. rotationEnabled: boolean;
  49582. /**
  49583. * constructs a new anchor system
  49584. * @param _xrSessionManager an instance of WebXRSessionManager
  49585. * @param _options configuration object for this feature
  49586. */
  49587. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  49588. /**
  49589. * Get the snapPointsOnly flag
  49590. */
  49591. get snapPointsOnly(): boolean;
  49592. /**
  49593. * Sets the snapPointsOnly flag
  49594. * @param snapToPoints should teleportation be exclusively to snap points
  49595. */
  49596. set snapPointsOnly(snapToPoints: boolean);
  49597. /**
  49598. * Add a new mesh to the floor meshes array
  49599. * @param mesh the mesh to use as floor mesh
  49600. */
  49601. addFloorMesh(mesh: AbstractMesh): void;
  49602. /**
  49603. * Add a new snap-to point to fix teleportation to this position
  49604. * @param newSnapPoint The new Snap-To point
  49605. */
  49606. addSnapPoint(newSnapPoint: Vector3): void;
  49607. attach(): boolean;
  49608. detach(): boolean;
  49609. dispose(): void;
  49610. /**
  49611. * Remove a mesh from the floor meshes array
  49612. * @param mesh the mesh to remove
  49613. */
  49614. removeFloorMesh(mesh: AbstractMesh): void;
  49615. /**
  49616. * Remove a mesh from the floor meshes array using its name
  49617. * @param name the mesh name to remove
  49618. */
  49619. removeFloorMeshByName(name: string): void;
  49620. /**
  49621. * 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
  49622. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  49623. * @returns was the point found and removed or not
  49624. */
  49625. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  49626. /**
  49627. * This function sets a selection feature that will be disabled when
  49628. * the forward ray is shown and will be reattached when hidden.
  49629. * This is used to remove the selection rays when moving.
  49630. * @param selectionFeature the feature to disable when forward movement is enabled
  49631. */
  49632. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  49633. protected _onXRFrame(_xrFrame: XRFrame): void;
  49634. private _attachController;
  49635. private _createDefaultTargetMesh;
  49636. private _detachController;
  49637. private _findClosestSnapPointWithRadius;
  49638. private _setTargetMeshPosition;
  49639. private _setTargetMeshVisibility;
  49640. private _showParabolicPath;
  49641. private _teleportForward;
  49642. }
  49643. }
  49644. declare module BABYLON {
  49645. /**
  49646. * Options for the default xr helper
  49647. */
  49648. export class WebXRDefaultExperienceOptions {
  49649. /**
  49650. * Enable or disable default UI to enter XR
  49651. */
  49652. disableDefaultUI?: boolean;
  49653. /**
  49654. * Should teleportation not initialize. defaults to false.
  49655. */
  49656. disableTeleportation?: boolean;
  49657. /**
  49658. * Floor meshes that will be used for teleport
  49659. */
  49660. floorMeshes?: Array<AbstractMesh>;
  49661. /**
  49662. * If set to true, the first frame will not be used to reset position
  49663. * The first frame is mainly used when copying transformation from the old camera
  49664. * Mainly used in AR
  49665. */
  49666. ignoreNativeCameraTransformation?: boolean;
  49667. /**
  49668. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  49669. */
  49670. inputOptions?: IWebXRInputOptions;
  49671. /**
  49672. * optional configuration for the output canvas
  49673. */
  49674. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  49675. /**
  49676. * optional UI options. This can be used among other to change session mode and reference space type
  49677. */
  49678. uiOptions?: WebXREnterExitUIOptions;
  49679. /**
  49680. * When loading teleportation and pointer select, use stable versions instead of latest.
  49681. */
  49682. useStablePlugins?: boolean;
  49683. /**
  49684. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  49685. */
  49686. renderingGroupId?: number;
  49687. /**
  49688. * A list of optional features to init the session with
  49689. * If set to true, all features we support will be added
  49690. */
  49691. optionalFeatures?: boolean | string[];
  49692. }
  49693. /**
  49694. * Default experience which provides a similar setup to the previous webVRExperience
  49695. */
  49696. export class WebXRDefaultExperience {
  49697. /**
  49698. * Base experience
  49699. */
  49700. baseExperience: WebXRExperienceHelper;
  49701. /**
  49702. * Enables ui for entering/exiting xr
  49703. */
  49704. enterExitUI: WebXREnterExitUI;
  49705. /**
  49706. * Input experience extension
  49707. */
  49708. input: WebXRInput;
  49709. /**
  49710. * Enables laser pointer and selection
  49711. */
  49712. pointerSelection: WebXRControllerPointerSelection;
  49713. /**
  49714. * Default target xr should render to
  49715. */
  49716. renderTarget: WebXRRenderTarget;
  49717. /**
  49718. * Enables teleportation
  49719. */
  49720. teleportation: WebXRMotionControllerTeleportation;
  49721. private constructor();
  49722. /**
  49723. * Creates the default xr experience
  49724. * @param scene scene
  49725. * @param options options for basic configuration
  49726. * @returns resulting WebXRDefaultExperience
  49727. */
  49728. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49729. /**
  49730. * DIsposes of the experience helper
  49731. */
  49732. dispose(): void;
  49733. }
  49734. }
  49735. declare module BABYLON {
  49736. /**
  49737. * Options to modify the vr teleportation behavior.
  49738. */
  49739. export interface VRTeleportationOptions {
  49740. /**
  49741. * The name of the mesh which should be used as the teleportation floor. (default: null)
  49742. */
  49743. floorMeshName?: string;
  49744. /**
  49745. * A list of meshes to be used as the teleportation floor. (default: empty)
  49746. */
  49747. floorMeshes?: Mesh[];
  49748. /**
  49749. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  49750. */
  49751. teleportationMode?: number;
  49752. /**
  49753. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  49754. */
  49755. teleportationTime?: number;
  49756. /**
  49757. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  49758. */
  49759. teleportationSpeed?: number;
  49760. /**
  49761. * The easing function used in the animation or null for Linear. (default CircleEase)
  49762. */
  49763. easingFunction?: EasingFunction;
  49764. }
  49765. /**
  49766. * Options to modify the vr experience helper's behavior.
  49767. */
  49768. export interface VRExperienceHelperOptions extends WebVROptions {
  49769. /**
  49770. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  49771. */
  49772. createDeviceOrientationCamera?: boolean;
  49773. /**
  49774. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  49775. */
  49776. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  49777. /**
  49778. * Uses the main button on the controller to toggle the laser casted. (default: true)
  49779. */
  49780. laserToggle?: boolean;
  49781. /**
  49782. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  49783. */
  49784. floorMeshes?: Mesh[];
  49785. /**
  49786. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  49787. */
  49788. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  49789. /**
  49790. * Defines if WebXR should be used instead of WebVR (if available)
  49791. */
  49792. useXR?: boolean;
  49793. }
  49794. /**
  49795. * Event containing information after VR has been entered
  49796. */
  49797. export class OnAfterEnteringVRObservableEvent {
  49798. /**
  49799. * If entering vr was successful
  49800. */
  49801. success: boolean;
  49802. }
  49803. /**
  49804. * Helps to quickly add VR support to an existing scene.
  49805. * See https://doc.babylonjs.com/how_to/webvr_helper
  49806. */
  49807. export class VRExperienceHelper {
  49808. /** Options to modify the vr experience helper's behavior. */
  49809. webVROptions: VRExperienceHelperOptions;
  49810. private _scene;
  49811. private _position;
  49812. private _btnVR;
  49813. private _btnVRDisplayed;
  49814. private _webVRsupported;
  49815. private _webVRready;
  49816. private _webVRrequesting;
  49817. private _webVRpresenting;
  49818. private _hasEnteredVR;
  49819. private _fullscreenVRpresenting;
  49820. private _inputElement;
  49821. private _webVRCamera;
  49822. private _vrDeviceOrientationCamera;
  49823. private _deviceOrientationCamera;
  49824. private _existingCamera;
  49825. private _onKeyDown;
  49826. private _onVrDisplayPresentChange;
  49827. private _onVRDisplayChanged;
  49828. private _onVRRequestPresentStart;
  49829. private _onVRRequestPresentComplete;
  49830. /**
  49831. * 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)
  49832. */
  49833. enableGazeEvenWhenNoPointerLock: boolean;
  49834. /**
  49835. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  49836. */
  49837. exitVROnDoubleTap: boolean;
  49838. /**
  49839. * Observable raised right before entering VR.
  49840. */
  49841. onEnteringVRObservable: Observable<VRExperienceHelper>;
  49842. /**
  49843. * Observable raised when entering VR has completed.
  49844. */
  49845. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  49846. /**
  49847. * Observable raised when exiting VR.
  49848. */
  49849. onExitingVRObservable: Observable<VRExperienceHelper>;
  49850. /**
  49851. * Observable raised when controller mesh is loaded.
  49852. */
  49853. onControllerMeshLoadedObservable: Observable<WebVRController>;
  49854. /** Return this.onEnteringVRObservable
  49855. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  49856. */
  49857. get onEnteringVR(): Observable<VRExperienceHelper>;
  49858. /** Return this.onExitingVRObservable
  49859. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  49860. */
  49861. get onExitingVR(): Observable<VRExperienceHelper>;
  49862. /** Return this.onControllerMeshLoadedObservable
  49863. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  49864. */
  49865. get onControllerMeshLoaded(): Observable<WebVRController>;
  49866. private _rayLength;
  49867. private _useCustomVRButton;
  49868. private _teleportationRequested;
  49869. private _teleportActive;
  49870. private _floorMeshName;
  49871. private _floorMeshesCollection;
  49872. private _teleportationMode;
  49873. private _teleportationTime;
  49874. private _teleportationSpeed;
  49875. private _teleportationEasing;
  49876. private _rotationAllowed;
  49877. private _teleportBackwardsVector;
  49878. private _teleportationTarget;
  49879. private _isDefaultTeleportationTarget;
  49880. private _postProcessMove;
  49881. private _teleportationFillColor;
  49882. private _teleportationBorderColor;
  49883. private _rotationAngle;
  49884. private _haloCenter;
  49885. private _cameraGazer;
  49886. private _padSensibilityUp;
  49887. private _padSensibilityDown;
  49888. private _leftController;
  49889. private _rightController;
  49890. private _gazeColor;
  49891. private _laserColor;
  49892. private _pickedLaserColor;
  49893. private _pickedGazeColor;
  49894. /**
  49895. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  49896. */
  49897. onNewMeshSelected: Observable<AbstractMesh>;
  49898. /**
  49899. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  49900. * This observable will provide the mesh and the controller used to select the mesh
  49901. */
  49902. onMeshSelectedWithController: Observable<{
  49903. mesh: AbstractMesh;
  49904. controller: WebVRController;
  49905. }>;
  49906. /**
  49907. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  49908. */
  49909. onNewMeshPicked: Observable<PickingInfo>;
  49910. private _circleEase;
  49911. /**
  49912. * Observable raised before camera teleportation
  49913. */
  49914. onBeforeCameraTeleport: Observable<Vector3>;
  49915. /**
  49916. * Observable raised after camera teleportation
  49917. */
  49918. onAfterCameraTeleport: Observable<Vector3>;
  49919. /**
  49920. * Observable raised when current selected mesh gets unselected
  49921. */
  49922. onSelectedMeshUnselected: Observable<AbstractMesh>;
  49923. private _raySelectionPredicate;
  49924. /**
  49925. * To be optionaly changed by user to define custom ray selection
  49926. */
  49927. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49928. /**
  49929. * To be optionaly changed by user to define custom selection logic (after ray selection)
  49930. */
  49931. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49932. /**
  49933. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  49934. */
  49935. teleportationEnabled: boolean;
  49936. private _defaultHeight;
  49937. private _teleportationInitialized;
  49938. private _interactionsEnabled;
  49939. private _interactionsRequested;
  49940. private _displayGaze;
  49941. private _displayLaserPointer;
  49942. /**
  49943. * The mesh used to display where the user is going to teleport.
  49944. */
  49945. get teleportationTarget(): Mesh;
  49946. /**
  49947. * Sets the mesh to be used to display where the user is going to teleport.
  49948. */
  49949. set teleportationTarget(value: Mesh);
  49950. /**
  49951. * 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
  49952. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  49953. * See https://doc.babylonjs.com/resources/baking_transformations
  49954. */
  49955. get gazeTrackerMesh(): Mesh;
  49956. set gazeTrackerMesh(value: Mesh);
  49957. /**
  49958. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  49959. */
  49960. updateGazeTrackerScale: boolean;
  49961. /**
  49962. * If the gaze trackers color should be updated when selecting meshes
  49963. */
  49964. updateGazeTrackerColor: boolean;
  49965. /**
  49966. * If the controller laser color should be updated when selecting meshes
  49967. */
  49968. updateControllerLaserColor: boolean;
  49969. /**
  49970. * The gaze tracking mesh corresponding to the left controller
  49971. */
  49972. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  49973. /**
  49974. * The gaze tracking mesh corresponding to the right controller
  49975. */
  49976. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  49977. /**
  49978. * If the ray of the gaze should be displayed.
  49979. */
  49980. get displayGaze(): boolean;
  49981. /**
  49982. * Sets if the ray of the gaze should be displayed.
  49983. */
  49984. set displayGaze(value: boolean);
  49985. /**
  49986. * If the ray of the LaserPointer should be displayed.
  49987. */
  49988. get displayLaserPointer(): boolean;
  49989. /**
  49990. * Sets if the ray of the LaserPointer should be displayed.
  49991. */
  49992. set displayLaserPointer(value: boolean);
  49993. /**
  49994. * The deviceOrientationCamera used as the camera when not in VR.
  49995. */
  49996. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  49997. /**
  49998. * Based on the current WebVR support, returns the current VR camera used.
  49999. */
  50000. get currentVRCamera(): Nullable<Camera>;
  50001. /**
  50002. * The webVRCamera which is used when in VR.
  50003. */
  50004. get webVRCamera(): WebVRFreeCamera;
  50005. /**
  50006. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  50007. */
  50008. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  50009. /**
  50010. * The html button that is used to trigger entering into VR.
  50011. */
  50012. get vrButton(): Nullable<HTMLButtonElement>;
  50013. private get _teleportationRequestInitiated();
  50014. /**
  50015. * Defines whether or not Pointer lock should be requested when switching to
  50016. * full screen.
  50017. */
  50018. requestPointerLockOnFullScreen: boolean;
  50019. /**
  50020. * If asking to force XR, this will be populated with the default xr experience
  50021. */
  50022. xr: WebXRDefaultExperience;
  50023. /**
  50024. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  50025. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  50026. */
  50027. xrTestDone: boolean;
  50028. /**
  50029. * Instantiates a VRExperienceHelper.
  50030. * Helps to quickly add VR support to an existing scene.
  50031. * @param scene The scene the VRExperienceHelper belongs to.
  50032. * @param webVROptions Options to modify the vr experience helper's behavior.
  50033. */
  50034. constructor(scene: Scene,
  50035. /** Options to modify the vr experience helper's behavior. */
  50036. webVROptions?: VRExperienceHelperOptions);
  50037. private completeVRInit;
  50038. private _onDefaultMeshLoaded;
  50039. private _onResize;
  50040. private _onFullscreenChange;
  50041. /**
  50042. * Gets a value indicating if we are currently in VR mode.
  50043. */
  50044. get isInVRMode(): boolean;
  50045. private onVrDisplayPresentChange;
  50046. private onVRDisplayChanged;
  50047. private moveButtonToBottomRight;
  50048. private displayVRButton;
  50049. private updateButtonVisibility;
  50050. private _cachedAngularSensibility;
  50051. /**
  50052. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  50053. * Otherwise, will use the fullscreen API.
  50054. */
  50055. enterVR(): void;
  50056. /**
  50057. * Attempt to exit VR, or fullscreen.
  50058. */
  50059. exitVR(): void;
  50060. /**
  50061. * The position of the vr experience helper.
  50062. */
  50063. get position(): Vector3;
  50064. /**
  50065. * Sets the position of the vr experience helper.
  50066. */
  50067. set position(value: Vector3);
  50068. /**
  50069. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  50070. */
  50071. enableInteractions(): void;
  50072. private get _noControllerIsActive();
  50073. private beforeRender;
  50074. private _isTeleportationFloor;
  50075. /**
  50076. * Adds a floor mesh to be used for teleportation.
  50077. * @param floorMesh the mesh to be used for teleportation.
  50078. */
  50079. addFloorMesh(floorMesh: Mesh): void;
  50080. /**
  50081. * Removes a floor mesh from being used for teleportation.
  50082. * @param floorMesh the mesh to be removed.
  50083. */
  50084. removeFloorMesh(floorMesh: Mesh): void;
  50085. /**
  50086. * Enables interactions and teleportation using the VR controllers and gaze.
  50087. * @param vrTeleportationOptions options to modify teleportation behavior.
  50088. */
  50089. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  50090. private _onNewGamepadConnected;
  50091. private _tryEnableInteractionOnController;
  50092. private _onNewGamepadDisconnected;
  50093. private _enableInteractionOnController;
  50094. private _checkTeleportWithRay;
  50095. private _checkRotate;
  50096. private _checkTeleportBackwards;
  50097. private _enableTeleportationOnController;
  50098. private _createTeleportationCircles;
  50099. private _displayTeleportationTarget;
  50100. private _hideTeleportationTarget;
  50101. private _rotateCamera;
  50102. private _moveTeleportationSelectorTo;
  50103. private _workingVector;
  50104. private _workingQuaternion;
  50105. private _workingMatrix;
  50106. /**
  50107. * Time Constant Teleportation Mode
  50108. */
  50109. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  50110. /**
  50111. * Speed Constant Teleportation Mode
  50112. */
  50113. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  50114. /**
  50115. * Teleports the users feet to the desired location
  50116. * @param location The location where the user's feet should be placed
  50117. */
  50118. teleportCamera(location: Vector3): void;
  50119. private _convertNormalToDirectionOfRay;
  50120. private _castRayAndSelectObject;
  50121. private _notifySelectedMeshUnselected;
  50122. /**
  50123. * Permanently set new colors for the laser pointer
  50124. * @param color the new laser color
  50125. * @param pickedColor the new laser color when picked mesh detected
  50126. */
  50127. setLaserColor(color: Color3, pickedColor?: Color3): void;
  50128. /**
  50129. * Set lighting enabled / disabled on the laser pointer of both controllers
  50130. * @param enabled should the lighting be enabled on the laser pointer
  50131. */
  50132. setLaserLightingState(enabled?: boolean): void;
  50133. /**
  50134. * Permanently set new colors for the gaze pointer
  50135. * @param color the new gaze color
  50136. * @param pickedColor the new gaze color when picked mesh detected
  50137. */
  50138. setGazeColor(color: Color3, pickedColor?: Color3): void;
  50139. /**
  50140. * Sets the color of the laser ray from the vr controllers.
  50141. * @param color new color for the ray.
  50142. */
  50143. changeLaserColor(color: Color3): void;
  50144. /**
  50145. * Sets the color of the ray from the vr headsets gaze.
  50146. * @param color new color for the ray.
  50147. */
  50148. changeGazeColor(color: Color3): void;
  50149. /**
  50150. * Exits VR and disposes of the vr experience helper
  50151. */
  50152. dispose(): void;
  50153. /**
  50154. * Gets the name of the VRExperienceHelper class
  50155. * @returns "VRExperienceHelper"
  50156. */
  50157. getClassName(): string;
  50158. }
  50159. }
  50160. declare module BABYLON {
  50161. /**
  50162. * Contains an array of blocks representing the octree
  50163. */
  50164. export interface IOctreeContainer<T> {
  50165. /**
  50166. * Blocks within the octree
  50167. */
  50168. blocks: Array<OctreeBlock<T>>;
  50169. }
  50170. /**
  50171. * Class used to store a cell in an octree
  50172. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50173. */
  50174. export class OctreeBlock<T> {
  50175. /**
  50176. * Gets the content of the current block
  50177. */
  50178. entries: T[];
  50179. /**
  50180. * Gets the list of block children
  50181. */
  50182. blocks: Array<OctreeBlock<T>>;
  50183. private _depth;
  50184. private _maxDepth;
  50185. private _capacity;
  50186. private _minPoint;
  50187. private _maxPoint;
  50188. private _boundingVectors;
  50189. private _creationFunc;
  50190. /**
  50191. * Creates a new block
  50192. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  50193. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  50194. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50195. * @param depth defines the current depth of this block in the octree
  50196. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  50197. * @param creationFunc defines a callback to call when an element is added to the block
  50198. */
  50199. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  50200. /**
  50201. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50202. */
  50203. get capacity(): number;
  50204. /**
  50205. * Gets the minimum vector (in world space) of the block's bounding box
  50206. */
  50207. get minPoint(): Vector3;
  50208. /**
  50209. * Gets the maximum vector (in world space) of the block's bounding box
  50210. */
  50211. get maxPoint(): Vector3;
  50212. /**
  50213. * Add a new element to this block
  50214. * @param entry defines the element to add
  50215. */
  50216. addEntry(entry: T): void;
  50217. /**
  50218. * Remove an element from this block
  50219. * @param entry defines the element to remove
  50220. */
  50221. removeEntry(entry: T): void;
  50222. /**
  50223. * Add an array of elements to this block
  50224. * @param entries defines the array of elements to add
  50225. */
  50226. addEntries(entries: T[]): void;
  50227. /**
  50228. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  50229. * @param frustumPlanes defines the frustum planes to test
  50230. * @param selection defines the array to store current content if selection is positive
  50231. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50232. */
  50233. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50234. /**
  50235. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  50236. * @param sphereCenter defines the bounding sphere center
  50237. * @param sphereRadius defines the bounding sphere radius
  50238. * @param selection defines the array to store current content if selection is positive
  50239. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50240. */
  50241. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50242. /**
  50243. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  50244. * @param ray defines the ray to test with
  50245. * @param selection defines the array to store current content if selection is positive
  50246. */
  50247. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  50248. /**
  50249. * Subdivide the content into child blocks (this block will then be empty)
  50250. */
  50251. createInnerBlocks(): void;
  50252. /**
  50253. * @hidden
  50254. */
  50255. 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;
  50256. }
  50257. }
  50258. declare module BABYLON {
  50259. /**
  50260. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  50261. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50262. */
  50263. export class Octree<T> {
  50264. /** 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.) */
  50265. maxDepth: number;
  50266. /**
  50267. * Blocks within the octree containing objects
  50268. */
  50269. blocks: Array<OctreeBlock<T>>;
  50270. /**
  50271. * Content stored in the octree
  50272. */
  50273. dynamicContent: T[];
  50274. private _maxBlockCapacity;
  50275. private _selectionContent;
  50276. private _creationFunc;
  50277. /**
  50278. * Creates a octree
  50279. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50280. * @param creationFunc function to be used to instatiate the octree
  50281. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  50282. * @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.)
  50283. */
  50284. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  50285. /** 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.) */
  50286. maxDepth?: number);
  50287. /**
  50288. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  50289. * @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);
  50290. * @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);
  50291. * @param entries meshes to be added to the octree blocks
  50292. */
  50293. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  50294. /**
  50295. * Adds a mesh to the octree
  50296. * @param entry Mesh to add to the octree
  50297. */
  50298. addMesh(entry: T): void;
  50299. /**
  50300. * Remove an element from the octree
  50301. * @param entry defines the element to remove
  50302. */
  50303. removeMesh(entry: T): void;
  50304. /**
  50305. * Selects an array of meshes within the frustum
  50306. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  50307. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  50308. * @returns array of meshes within the frustum
  50309. */
  50310. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  50311. /**
  50312. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  50313. * @param sphereCenter defines the bounding sphere center
  50314. * @param sphereRadius defines the bounding sphere radius
  50315. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50316. * @returns an array of objects that intersect the sphere
  50317. */
  50318. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  50319. /**
  50320. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  50321. * @param ray defines the ray to test with
  50322. * @returns array of intersected objects
  50323. */
  50324. intersectsRay(ray: Ray): SmartArray<T>;
  50325. /**
  50326. * Adds a mesh into the octree block if it intersects the block
  50327. */
  50328. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  50329. /**
  50330. * Adds a submesh into the octree block if it intersects the block
  50331. */
  50332. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  50333. }
  50334. }
  50335. declare module BABYLON {
  50336. interface Scene {
  50337. /**
  50338. * @hidden
  50339. * Backing Filed
  50340. */
  50341. _selectionOctree: Octree<AbstractMesh>;
  50342. /**
  50343. * Gets the octree used to boost mesh selection (picking)
  50344. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50345. */
  50346. selectionOctree: Octree<AbstractMesh>;
  50347. /**
  50348. * Creates or updates the octree used to boost selection (picking)
  50349. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50350. * @param maxCapacity defines the maximum capacity per leaf
  50351. * @param maxDepth defines the maximum depth of the octree
  50352. * @returns an octree of AbstractMesh
  50353. */
  50354. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  50355. }
  50356. interface AbstractMesh {
  50357. /**
  50358. * @hidden
  50359. * Backing Field
  50360. */
  50361. _submeshesOctree: Octree<SubMesh>;
  50362. /**
  50363. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  50364. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  50365. * @param maxCapacity defines the maximum size of each block (64 by default)
  50366. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  50367. * @returns the new octree
  50368. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  50369. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50370. */
  50371. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  50372. }
  50373. /**
  50374. * Defines the octree scene component responsible to manage any octrees
  50375. * in a given scene.
  50376. */
  50377. export class OctreeSceneComponent {
  50378. /**
  50379. * The component name help to identify the component in the list of scene components.
  50380. */
  50381. readonly name: string;
  50382. /**
  50383. * The scene the component belongs to.
  50384. */
  50385. scene: Scene;
  50386. /**
  50387. * Indicates if the meshes have been checked to make sure they are isEnabled()
  50388. */
  50389. readonly checksIsEnabled: boolean;
  50390. /**
  50391. * Creates a new instance of the component for the given scene
  50392. * @param scene Defines the scene to register the component in
  50393. */
  50394. constructor(scene: Scene);
  50395. /**
  50396. * Registers the component in a given scene
  50397. */
  50398. register(): void;
  50399. /**
  50400. * Return the list of active meshes
  50401. * @returns the list of active meshes
  50402. */
  50403. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  50404. /**
  50405. * Return the list of active sub meshes
  50406. * @param mesh The mesh to get the candidates sub meshes from
  50407. * @returns the list of active sub meshes
  50408. */
  50409. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  50410. private _tempRay;
  50411. /**
  50412. * Return the list of sub meshes intersecting with a given local ray
  50413. * @param mesh defines the mesh to find the submesh for
  50414. * @param localRay defines the ray in local space
  50415. * @returns the list of intersecting sub meshes
  50416. */
  50417. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  50418. /**
  50419. * Return the list of sub meshes colliding with a collider
  50420. * @param mesh defines the mesh to find the submesh for
  50421. * @param collider defines the collider to evaluate the collision against
  50422. * @returns the list of colliding sub meshes
  50423. */
  50424. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  50425. /**
  50426. * Rebuilds the elements related to this component in case of
  50427. * context lost for instance.
  50428. */
  50429. rebuild(): void;
  50430. /**
  50431. * Disposes the component and the associated ressources.
  50432. */
  50433. dispose(): void;
  50434. }
  50435. }
  50436. declare module BABYLON {
  50437. /**
  50438. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  50439. */
  50440. export class Gizmo implements IDisposable {
  50441. /** The utility layer the gizmo will be added to */
  50442. gizmoLayer: UtilityLayerRenderer;
  50443. /**
  50444. * The root mesh of the gizmo
  50445. */
  50446. _rootMesh: Mesh;
  50447. private _attachedMesh;
  50448. private _attachedNode;
  50449. /**
  50450. * Ratio for the scale of the gizmo (Default: 1)
  50451. */
  50452. protected _scaleRatio: number;
  50453. /**
  50454. * boolean updated by pointermove when a gizmo mesh is hovered
  50455. */
  50456. protected _isHovered: boolean;
  50457. /**
  50458. * Ratio for the scale of the gizmo (Default: 1)
  50459. */
  50460. set scaleRatio(value: number);
  50461. get scaleRatio(): number;
  50462. /**
  50463. * True when the mouse pointer is hovered a gizmo mesh
  50464. */
  50465. get isHovered(): boolean;
  50466. /**
  50467. * If a custom mesh has been set (Default: false)
  50468. */
  50469. protected _customMeshSet: boolean;
  50470. /**
  50471. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  50472. * * When set, interactions will be enabled
  50473. */
  50474. get attachedMesh(): Nullable<AbstractMesh>;
  50475. set attachedMesh(value: Nullable<AbstractMesh>);
  50476. /**
  50477. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  50478. * * When set, interactions will be enabled
  50479. */
  50480. get attachedNode(): Nullable<Node>;
  50481. set attachedNode(value: Nullable<Node>);
  50482. /**
  50483. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50484. * @param mesh The mesh to replace the default mesh of the gizmo
  50485. */
  50486. setCustomMesh(mesh: Mesh): void;
  50487. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  50488. /**
  50489. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  50490. */
  50491. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50492. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50493. /**
  50494. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  50495. */
  50496. updateGizmoPositionToMatchAttachedMesh: boolean;
  50497. /**
  50498. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  50499. */
  50500. updateScale: boolean;
  50501. protected _interactionsEnabled: boolean;
  50502. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50503. private _beforeRenderObserver;
  50504. private _tempQuaternion;
  50505. private _tempVector;
  50506. private _tempVector2;
  50507. private _tempMatrix1;
  50508. private _tempMatrix2;
  50509. private _rightHandtoLeftHandMatrix;
  50510. /**
  50511. * Creates a gizmo
  50512. * @param gizmoLayer The utility layer the gizmo will be added to
  50513. */
  50514. constructor(
  50515. /** The utility layer the gizmo will be added to */
  50516. gizmoLayer?: UtilityLayerRenderer);
  50517. /**
  50518. * Updates the gizmo to match the attached mesh's position/rotation
  50519. */
  50520. protected _update(): void;
  50521. /**
  50522. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  50523. * @param value Node, TransformNode or mesh
  50524. */
  50525. protected _matrixChanged(): void;
  50526. /**
  50527. * Disposes of the gizmo
  50528. */
  50529. dispose(): void;
  50530. }
  50531. }
  50532. declare module BABYLON {
  50533. /**
  50534. * Single plane drag gizmo
  50535. */
  50536. export class PlaneDragGizmo extends Gizmo {
  50537. /**
  50538. * Drag behavior responsible for the gizmos dragging interactions
  50539. */
  50540. dragBehavior: PointerDragBehavior;
  50541. private _pointerObserver;
  50542. /**
  50543. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50544. */
  50545. snapDistance: number;
  50546. /**
  50547. * Event that fires each time the gizmo snaps to a new location.
  50548. * * snapDistance is the the change in distance
  50549. */
  50550. onSnapObservable: Observable<{
  50551. snapDistance: number;
  50552. }>;
  50553. private _plane;
  50554. private _coloredMaterial;
  50555. private _hoverMaterial;
  50556. private _isEnabled;
  50557. private _parent;
  50558. /** @hidden */
  50559. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  50560. /** @hidden */
  50561. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50562. /**
  50563. * Creates a PlaneDragGizmo
  50564. * @param gizmoLayer The utility layer the gizmo will be added to
  50565. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  50566. * @param color The color of the gizmo
  50567. */
  50568. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  50569. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50570. /**
  50571. * If the gizmo is enabled
  50572. */
  50573. set isEnabled(value: boolean);
  50574. get isEnabled(): boolean;
  50575. /**
  50576. * Disposes of the gizmo
  50577. */
  50578. dispose(): void;
  50579. }
  50580. }
  50581. declare module BABYLON {
  50582. /**
  50583. * Gizmo that enables dragging a mesh along 3 axis
  50584. */
  50585. export class PositionGizmo extends Gizmo {
  50586. /**
  50587. * Internal gizmo used for interactions on the x axis
  50588. */
  50589. xGizmo: AxisDragGizmo;
  50590. /**
  50591. * Internal gizmo used for interactions on the y axis
  50592. */
  50593. yGizmo: AxisDragGizmo;
  50594. /**
  50595. * Internal gizmo used for interactions on the z axis
  50596. */
  50597. zGizmo: AxisDragGizmo;
  50598. /**
  50599. * Internal gizmo used for interactions on the yz plane
  50600. */
  50601. xPlaneGizmo: PlaneDragGizmo;
  50602. /**
  50603. * Internal gizmo used for interactions on the xz plane
  50604. */
  50605. yPlaneGizmo: PlaneDragGizmo;
  50606. /**
  50607. * Internal gizmo used for interactions on the xy plane
  50608. */
  50609. zPlaneGizmo: PlaneDragGizmo;
  50610. /**
  50611. * private variables
  50612. */
  50613. private _meshAttached;
  50614. private _nodeAttached;
  50615. private _snapDistance;
  50616. /** Fires an event when any of it's sub gizmos are dragged */
  50617. onDragStartObservable: Observable<unknown>;
  50618. /** Fires an event when any of it's sub gizmos are released from dragging */
  50619. onDragEndObservable: Observable<unknown>;
  50620. /**
  50621. * If set to true, planar drag is enabled
  50622. */
  50623. private _planarGizmoEnabled;
  50624. get attachedMesh(): Nullable<AbstractMesh>;
  50625. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50626. get attachedNode(): Nullable<Node>;
  50627. set attachedNode(node: Nullable<Node>);
  50628. /**
  50629. * True when the mouse pointer is hovering a gizmo mesh
  50630. */
  50631. get isHovered(): boolean;
  50632. /**
  50633. * Creates a PositionGizmo
  50634. * @param gizmoLayer The utility layer the gizmo will be added to
  50635. @param thickness display gizmo axis thickness
  50636. */
  50637. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  50638. /**
  50639. * If the planar drag gizmo is enabled
  50640. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  50641. */
  50642. set planarGizmoEnabled(value: boolean);
  50643. get planarGizmoEnabled(): boolean;
  50644. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50645. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50646. /**
  50647. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50648. */
  50649. set snapDistance(value: number);
  50650. get snapDistance(): number;
  50651. /**
  50652. * Ratio for the scale of the gizmo (Default: 1)
  50653. */
  50654. set scaleRatio(value: number);
  50655. get scaleRatio(): number;
  50656. /**
  50657. * Disposes of the gizmo
  50658. */
  50659. dispose(): void;
  50660. /**
  50661. * CustomMeshes are not supported by this gizmo
  50662. * @param mesh The mesh to replace the default mesh of the gizmo
  50663. */
  50664. setCustomMesh(mesh: Mesh): void;
  50665. }
  50666. }
  50667. declare module BABYLON {
  50668. /**
  50669. * Single axis drag gizmo
  50670. */
  50671. export class AxisDragGizmo extends Gizmo {
  50672. /**
  50673. * Drag behavior responsible for the gizmos dragging interactions
  50674. */
  50675. dragBehavior: PointerDragBehavior;
  50676. private _pointerObserver;
  50677. /**
  50678. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50679. */
  50680. snapDistance: number;
  50681. /**
  50682. * Event that fires each time the gizmo snaps to a new location.
  50683. * * snapDistance is the the change in distance
  50684. */
  50685. onSnapObservable: Observable<{
  50686. snapDistance: number;
  50687. }>;
  50688. private _isEnabled;
  50689. private _parent;
  50690. private _arrow;
  50691. private _coloredMaterial;
  50692. private _hoverMaterial;
  50693. /** @hidden */
  50694. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  50695. /** @hidden */
  50696. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50697. /**
  50698. * Creates an AxisDragGizmo
  50699. * @param gizmoLayer The utility layer the gizmo will be added to
  50700. * @param dragAxis The axis which the gizmo will be able to drag on
  50701. * @param color The color of the gizmo
  50702. * @param thickness display gizmo axis thickness
  50703. */
  50704. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  50705. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50706. /**
  50707. * If the gizmo is enabled
  50708. */
  50709. set isEnabled(value: boolean);
  50710. get isEnabled(): boolean;
  50711. /**
  50712. * Disposes of the gizmo
  50713. */
  50714. dispose(): void;
  50715. }
  50716. }
  50717. declare module BABYLON.Debug {
  50718. /**
  50719. * The Axes viewer will show 3 axes in a specific point in space
  50720. */
  50721. export class AxesViewer {
  50722. private _xAxis;
  50723. private _yAxis;
  50724. private _zAxis;
  50725. private _scaleLinesFactor;
  50726. private _instanced;
  50727. /**
  50728. * Gets the hosting scene
  50729. */
  50730. scene: Nullable<Scene>;
  50731. /**
  50732. * Gets or sets a number used to scale line length
  50733. */
  50734. scaleLines: number;
  50735. /** Gets the node hierarchy used to render x-axis */
  50736. get xAxis(): TransformNode;
  50737. /** Gets the node hierarchy used to render y-axis */
  50738. get yAxis(): TransformNode;
  50739. /** Gets the node hierarchy used to render z-axis */
  50740. get zAxis(): TransformNode;
  50741. /**
  50742. * Creates a new AxesViewer
  50743. * @param scene defines the hosting scene
  50744. * @param scaleLines defines a number used to scale line length (1 by default)
  50745. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  50746. * @param xAxis defines the node hierarchy used to render the x-axis
  50747. * @param yAxis defines the node hierarchy used to render the y-axis
  50748. * @param zAxis defines the node hierarchy used to render the z-axis
  50749. */
  50750. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  50751. /**
  50752. * Force the viewer to update
  50753. * @param position defines the position of the viewer
  50754. * @param xaxis defines the x axis of the viewer
  50755. * @param yaxis defines the y axis of the viewer
  50756. * @param zaxis defines the z axis of the viewer
  50757. */
  50758. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  50759. /**
  50760. * Creates an instance of this axes viewer.
  50761. * @returns a new axes viewer with instanced meshes
  50762. */
  50763. createInstance(): AxesViewer;
  50764. /** Releases resources */
  50765. dispose(): void;
  50766. private static _SetRenderingGroupId;
  50767. }
  50768. }
  50769. declare module BABYLON.Debug {
  50770. /**
  50771. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  50772. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  50773. */
  50774. export class BoneAxesViewer extends AxesViewer {
  50775. /**
  50776. * Gets or sets the target mesh where to display the axes viewer
  50777. */
  50778. mesh: Nullable<Mesh>;
  50779. /**
  50780. * Gets or sets the target bone where to display the axes viewer
  50781. */
  50782. bone: Nullable<Bone>;
  50783. /** Gets current position */
  50784. pos: Vector3;
  50785. /** Gets direction of X axis */
  50786. xaxis: Vector3;
  50787. /** Gets direction of Y axis */
  50788. yaxis: Vector3;
  50789. /** Gets direction of Z axis */
  50790. zaxis: Vector3;
  50791. /**
  50792. * Creates a new BoneAxesViewer
  50793. * @param scene defines the hosting scene
  50794. * @param bone defines the target bone
  50795. * @param mesh defines the target mesh
  50796. * @param scaleLines defines a scaling factor for line length (1 by default)
  50797. */
  50798. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  50799. /**
  50800. * Force the viewer to update
  50801. */
  50802. update(): void;
  50803. /** Releases resources */
  50804. dispose(): void;
  50805. }
  50806. }
  50807. declare module BABYLON {
  50808. /**
  50809. * Interface used to define scene explorer extensibility option
  50810. */
  50811. export interface IExplorerExtensibilityOption {
  50812. /**
  50813. * Define the option label
  50814. */
  50815. label: string;
  50816. /**
  50817. * Defines the action to execute on click
  50818. */
  50819. action: (entity: any) => void;
  50820. }
  50821. /**
  50822. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  50823. */
  50824. export interface IExplorerExtensibilityGroup {
  50825. /**
  50826. * Defines a predicate to test if a given type mut be extended
  50827. */
  50828. predicate: (entity: any) => boolean;
  50829. /**
  50830. * Gets the list of options added to a type
  50831. */
  50832. entries: IExplorerExtensibilityOption[];
  50833. }
  50834. /**
  50835. * Interface used to define the options to use to create the Inspector
  50836. */
  50837. export interface IInspectorOptions {
  50838. /**
  50839. * Display in overlay mode (default: false)
  50840. */
  50841. overlay?: boolean;
  50842. /**
  50843. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  50844. */
  50845. globalRoot?: HTMLElement;
  50846. /**
  50847. * Display the Scene explorer
  50848. */
  50849. showExplorer?: boolean;
  50850. /**
  50851. * Display the property inspector
  50852. */
  50853. showInspector?: boolean;
  50854. /**
  50855. * Display in embed mode (both panes on the right)
  50856. */
  50857. embedMode?: boolean;
  50858. /**
  50859. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  50860. */
  50861. handleResize?: boolean;
  50862. /**
  50863. * Allow the panes to popup (default: true)
  50864. */
  50865. enablePopup?: boolean;
  50866. /**
  50867. * Allow the panes to be closed by users (default: true)
  50868. */
  50869. enableClose?: boolean;
  50870. /**
  50871. * Optional list of extensibility entries
  50872. */
  50873. explorerExtensibility?: IExplorerExtensibilityGroup[];
  50874. /**
  50875. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  50876. */
  50877. inspectorURL?: string;
  50878. /**
  50879. * Optional initial tab (default to DebugLayerTab.Properties)
  50880. */
  50881. initialTab?: DebugLayerTab;
  50882. }
  50883. interface Scene {
  50884. /**
  50885. * @hidden
  50886. * Backing field
  50887. */
  50888. _debugLayer: DebugLayer;
  50889. /**
  50890. * Gets the debug layer (aka Inspector) associated with the scene
  50891. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50892. */
  50893. debugLayer: DebugLayer;
  50894. }
  50895. /**
  50896. * Enum of inspector action tab
  50897. */
  50898. export enum DebugLayerTab {
  50899. /**
  50900. * Properties tag (default)
  50901. */
  50902. Properties = 0,
  50903. /**
  50904. * Debug tab
  50905. */
  50906. Debug = 1,
  50907. /**
  50908. * Statistics tab
  50909. */
  50910. Statistics = 2,
  50911. /**
  50912. * Tools tab
  50913. */
  50914. Tools = 3,
  50915. /**
  50916. * Settings tab
  50917. */
  50918. Settings = 4
  50919. }
  50920. /**
  50921. * The debug layer (aka Inspector) is the go to tool in order to better understand
  50922. * what is happening in your scene
  50923. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50924. */
  50925. export class DebugLayer {
  50926. /**
  50927. * Define the url to get the inspector script from.
  50928. * By default it uses the babylonjs CDN.
  50929. * @ignoreNaming
  50930. */
  50931. static InspectorURL: string;
  50932. private _scene;
  50933. private BJSINSPECTOR;
  50934. private _onPropertyChangedObservable?;
  50935. /**
  50936. * Observable triggered when a property is changed through the inspector.
  50937. */
  50938. get onPropertyChangedObservable(): any;
  50939. /**
  50940. * Instantiates a new debug layer.
  50941. * The debug layer (aka Inspector) is the go to tool in order to better understand
  50942. * what is happening in your scene
  50943. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50944. * @param scene Defines the scene to inspect
  50945. */
  50946. constructor(scene: Scene);
  50947. /** Creates the inspector window. */
  50948. private _createInspector;
  50949. /**
  50950. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  50951. * @param entity defines the entity to select
  50952. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  50953. */
  50954. select(entity: any, lineContainerTitles?: string | string[]): void;
  50955. /** Get the inspector from bundle or global */
  50956. private _getGlobalInspector;
  50957. /**
  50958. * Get if the inspector is visible or not.
  50959. * @returns true if visible otherwise, false
  50960. */
  50961. isVisible(): boolean;
  50962. /**
  50963. * Hide the inspector and close its window.
  50964. */
  50965. hide(): void;
  50966. /**
  50967. * Update the scene in the inspector
  50968. */
  50969. setAsActiveScene(): void;
  50970. /**
  50971. * Launch the debugLayer.
  50972. * @param config Define the configuration of the inspector
  50973. * @return a promise fulfilled when the debug layer is visible
  50974. */
  50975. show(config?: IInspectorOptions): Promise<DebugLayer>;
  50976. }
  50977. }
  50978. declare module BABYLON {
  50979. /**
  50980. * Class containing static functions to help procedurally build meshes
  50981. */
  50982. export class BoxBuilder {
  50983. /**
  50984. * Creates a box mesh
  50985. * * The parameter `size` sets the size (float) of each box side (default 1)
  50986. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50987. * * 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)
  50988. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50989. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50990. * * 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
  50991. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50992. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50993. * @param name defines the name of the mesh
  50994. * @param options defines the options used to create the mesh
  50995. * @param scene defines the hosting scene
  50996. * @returns the box mesh
  50997. */
  50998. static CreateBox(name: string, options: {
  50999. size?: number;
  51000. width?: number;
  51001. height?: number;
  51002. depth?: number;
  51003. faceUV?: Vector4[];
  51004. faceColors?: Color4[];
  51005. sideOrientation?: number;
  51006. frontUVs?: Vector4;
  51007. backUVs?: Vector4;
  51008. wrap?: boolean;
  51009. topBaseAt?: number;
  51010. bottomBaseAt?: number;
  51011. updatable?: boolean;
  51012. }, scene?: Nullable<Scene>): Mesh;
  51013. }
  51014. }
  51015. declare module BABYLON.Debug {
  51016. /**
  51017. * Used to show the physics impostor around the specific mesh
  51018. */
  51019. export class PhysicsViewer {
  51020. /** @hidden */
  51021. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  51022. /** @hidden */
  51023. protected _meshes: Array<Nullable<AbstractMesh>>;
  51024. /** @hidden */
  51025. protected _scene: Nullable<Scene>;
  51026. /** @hidden */
  51027. protected _numMeshes: number;
  51028. /** @hidden */
  51029. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  51030. private _renderFunction;
  51031. private _utilityLayer;
  51032. private _debugBoxMesh;
  51033. private _debugSphereMesh;
  51034. private _debugCylinderMesh;
  51035. private _debugMaterial;
  51036. private _debugMeshMeshes;
  51037. /**
  51038. * Creates a new PhysicsViewer
  51039. * @param scene defines the hosting scene
  51040. */
  51041. constructor(scene: Scene);
  51042. /** @hidden */
  51043. protected _updateDebugMeshes(): void;
  51044. /**
  51045. * Renders a specified physic impostor
  51046. * @param impostor defines the impostor to render
  51047. * @param targetMesh defines the mesh represented by the impostor
  51048. * @returns the new debug mesh used to render the impostor
  51049. */
  51050. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  51051. /**
  51052. * Hides a specified physic impostor
  51053. * @param impostor defines the impostor to hide
  51054. */
  51055. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  51056. private _getDebugMaterial;
  51057. private _getDebugBoxMesh;
  51058. private _getDebugSphereMesh;
  51059. private _getDebugCylinderMesh;
  51060. private _getDebugMeshMesh;
  51061. private _getDebugMesh;
  51062. /** Releases all resources */
  51063. dispose(): void;
  51064. }
  51065. }
  51066. declare module BABYLON {
  51067. /**
  51068. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  51069. * in order to better appreciate the issue one might have.
  51070. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  51071. */
  51072. export class RayHelper {
  51073. /**
  51074. * Defines the ray we are currently tryin to visualize.
  51075. */
  51076. ray: Nullable<Ray>;
  51077. private _renderPoints;
  51078. private _renderLine;
  51079. private _renderFunction;
  51080. private _scene;
  51081. private _onAfterRenderObserver;
  51082. private _onAfterStepObserver;
  51083. private _attachedToMesh;
  51084. private _meshSpaceDirection;
  51085. private _meshSpaceOrigin;
  51086. /**
  51087. * Helper function to create a colored helper in a scene in one line.
  51088. * @param ray Defines the ray we are currently tryin to visualize
  51089. * @param scene Defines the scene the ray is used in
  51090. * @param color Defines the color we want to see the ray in
  51091. * @returns The newly created ray helper.
  51092. */
  51093. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  51094. /**
  51095. * Instantiate a new ray helper.
  51096. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  51097. * in order to better appreciate the issue one might have.
  51098. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  51099. * @param ray Defines the ray we are currently tryin to visualize
  51100. */
  51101. constructor(ray: Ray);
  51102. /**
  51103. * Shows the ray we are willing to debug.
  51104. * @param scene Defines the scene the ray needs to be rendered in
  51105. * @param color Defines the color the ray needs to be rendered in
  51106. */
  51107. show(scene: Scene, color?: Color3): void;
  51108. /**
  51109. * Hides the ray we are debugging.
  51110. */
  51111. hide(): void;
  51112. private _render;
  51113. /**
  51114. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  51115. * @param mesh Defines the mesh we want the helper attached to
  51116. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  51117. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  51118. * @param length Defines the length of the ray
  51119. */
  51120. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  51121. /**
  51122. * Detach the ray helper from the mesh it has previously been attached to.
  51123. */
  51124. detachFromMesh(): void;
  51125. private _updateToMesh;
  51126. /**
  51127. * Dispose the helper and release its associated resources.
  51128. */
  51129. dispose(): void;
  51130. }
  51131. }
  51132. declare module BABYLON {
  51133. /**
  51134. * Defines the options associated with the creation of a SkeletonViewer.
  51135. */
  51136. export interface ISkeletonViewerOptions {
  51137. /** Should the system pause animations before building the Viewer? */
  51138. pauseAnimations: boolean;
  51139. /** Should the system return the skeleton to rest before building? */
  51140. returnToRest: boolean;
  51141. /** public Display Mode of the Viewer */
  51142. displayMode: number;
  51143. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  51144. displayOptions: ISkeletonViewerDisplayOptions;
  51145. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  51146. computeBonesUsingShaders: boolean;
  51147. /** Flag ignore non weighted bones */
  51148. useAllBones: boolean;
  51149. }
  51150. /**
  51151. * Defines how to display the various bone meshes for the viewer.
  51152. */
  51153. export interface ISkeletonViewerDisplayOptions {
  51154. /** How far down to start tapering the bone spurs */
  51155. midStep?: number;
  51156. /** How big is the midStep? */
  51157. midStepFactor?: number;
  51158. /** Base for the Sphere Size */
  51159. sphereBaseSize?: number;
  51160. /** The ratio of the sphere to the longest bone in units */
  51161. sphereScaleUnit?: number;
  51162. /** Ratio for the Sphere Size */
  51163. sphereFactor?: number;
  51164. /** Whether to show local axes or not */
  51165. showLocalAxes?: boolean;
  51166. /** Length of each local axis */
  51167. localAxesSize?: number;
  51168. }
  51169. /**
  51170. * Defines the constructor options for the BoneWeight Shader.
  51171. */
  51172. export interface IBoneWeightShaderOptions {
  51173. /** Skeleton to Map */
  51174. skeleton: Skeleton;
  51175. /** Colors for Uninfluenced bones */
  51176. colorBase?: Color3;
  51177. /** Colors for 0.0-0.25 Weight bones */
  51178. colorZero?: Color3;
  51179. /** Color for 0.25-0.5 Weight Influence */
  51180. colorQuarter?: Color3;
  51181. /** Color for 0.5-0.75 Weight Influence */
  51182. colorHalf?: Color3;
  51183. /** Color for 0.75-1 Weight Influence */
  51184. colorFull?: Color3;
  51185. /** Color for Zero Weight Influence */
  51186. targetBoneIndex?: number;
  51187. }
  51188. /**
  51189. * Simple structure of the gradient steps for the Color Map.
  51190. */
  51191. export interface ISkeletonMapShaderColorMapKnot {
  51192. /** Color of the Knot */
  51193. color: Color3;
  51194. /** Location of the Knot */
  51195. location: number;
  51196. }
  51197. /**
  51198. * Defines the constructor options for the SkeletonMap Shader.
  51199. */
  51200. export interface ISkeletonMapShaderOptions {
  51201. /** Skeleton to Map */
  51202. skeleton: Skeleton;
  51203. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  51204. colorMap?: ISkeletonMapShaderColorMapKnot[];
  51205. }
  51206. }
  51207. declare module BABYLON {
  51208. /**
  51209. * Class containing static functions to help procedurally build meshes
  51210. */
  51211. export class RibbonBuilder {
  51212. /**
  51213. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51214. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51215. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51216. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51217. * * 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
  51218. * * 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
  51219. * * 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
  51220. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51221. * * 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
  51222. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51223. * * 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
  51224. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51225. * * 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
  51226. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51227. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51228. * @param name defines the name of the mesh
  51229. * @param options defines the options used to create the mesh
  51230. * @param scene defines the hosting scene
  51231. * @returns the ribbon mesh
  51232. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51233. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51234. */
  51235. static CreateRibbon(name: string, options: {
  51236. pathArray: Vector3[][];
  51237. closeArray?: boolean;
  51238. closePath?: boolean;
  51239. offset?: number;
  51240. updatable?: boolean;
  51241. sideOrientation?: number;
  51242. frontUVs?: Vector4;
  51243. backUVs?: Vector4;
  51244. instance?: Mesh;
  51245. invertUV?: boolean;
  51246. uvs?: Vector2[];
  51247. colors?: Color4[];
  51248. }, scene?: Nullable<Scene>): Mesh;
  51249. }
  51250. }
  51251. declare module BABYLON {
  51252. /**
  51253. * Class containing static functions to help procedurally build meshes
  51254. */
  51255. export class ShapeBuilder {
  51256. /**
  51257. * 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.
  51258. * * 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.
  51259. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51260. * * 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.
  51261. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51262. * * 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
  51263. * * 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
  51264. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51265. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51266. * * 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
  51267. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51268. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51269. * @param name defines the name of the mesh
  51270. * @param options defines the options used to create the mesh
  51271. * @param scene defines the hosting scene
  51272. * @returns the extruded shape mesh
  51273. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51274. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51275. */
  51276. static ExtrudeShape(name: string, options: {
  51277. shape: Vector3[];
  51278. path: Vector3[];
  51279. scale?: number;
  51280. rotation?: number;
  51281. cap?: number;
  51282. updatable?: boolean;
  51283. sideOrientation?: number;
  51284. frontUVs?: Vector4;
  51285. backUVs?: Vector4;
  51286. instance?: Mesh;
  51287. invertUV?: boolean;
  51288. }, scene?: Nullable<Scene>): Mesh;
  51289. /**
  51290. * Creates an custom extruded shape mesh.
  51291. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51292. * * 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.
  51293. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51294. * * 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
  51295. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51296. * * 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
  51297. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51298. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51299. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51300. * * 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
  51301. * * 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
  51302. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51303. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51304. * * 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
  51305. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51306. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51307. * @param name defines the name of the mesh
  51308. * @param options defines the options used to create the mesh
  51309. * @param scene defines the hosting scene
  51310. * @returns the custom extruded shape mesh
  51311. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51312. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51313. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51314. */
  51315. static ExtrudeShapeCustom(name: string, options: {
  51316. shape: Vector3[];
  51317. path: Vector3[];
  51318. scaleFunction?: any;
  51319. rotationFunction?: any;
  51320. ribbonCloseArray?: boolean;
  51321. ribbonClosePath?: boolean;
  51322. cap?: number;
  51323. updatable?: boolean;
  51324. sideOrientation?: number;
  51325. frontUVs?: Vector4;
  51326. backUVs?: Vector4;
  51327. instance?: Mesh;
  51328. invertUV?: boolean;
  51329. }, scene?: Nullable<Scene>): Mesh;
  51330. private static _ExtrudeShapeGeneric;
  51331. }
  51332. }
  51333. declare module BABYLON.Debug {
  51334. /**
  51335. * Class used to render a debug view of a given skeleton
  51336. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  51337. */
  51338. export class SkeletonViewer {
  51339. /** defines the skeleton to render */
  51340. skeleton: Skeleton;
  51341. /** defines the mesh attached to the skeleton */
  51342. mesh: AbstractMesh;
  51343. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51344. autoUpdateBonesMatrices: boolean;
  51345. /** defines the rendering group id to use with the viewer */
  51346. renderingGroupId: number;
  51347. /** is the options for the viewer */
  51348. options: Partial<ISkeletonViewerOptions>;
  51349. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  51350. static readonly DISPLAY_LINES: number;
  51351. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  51352. static readonly DISPLAY_SPHERES: number;
  51353. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  51354. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  51355. /** public static method to create a BoneWeight Shader
  51356. * @param options The constructor options
  51357. * @param scene The scene that the shader is scoped to
  51358. * @returns The created ShaderMaterial
  51359. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  51360. */
  51361. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  51362. /** public static method to create a BoneWeight Shader
  51363. * @param options The constructor options
  51364. * @param scene The scene that the shader is scoped to
  51365. * @returns The created ShaderMaterial
  51366. */
  51367. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  51368. /** private static method to create a BoneWeight Shader
  51369. * @param size The size of the buffer to create (usually the bone count)
  51370. * @param colorMap The gradient data to generate
  51371. * @param scene The scene that the shader is scoped to
  51372. * @returns an Array of floats from the color gradient values
  51373. */
  51374. private static _CreateBoneMapColorBuffer;
  51375. /** If SkeletonViewer scene scope. */
  51376. private _scene;
  51377. /** Gets or sets the color used to render the skeleton */
  51378. color: Color3;
  51379. /** Array of the points of the skeleton fo the line view. */
  51380. private _debugLines;
  51381. /** The SkeletonViewers Mesh. */
  51382. private _debugMesh;
  51383. /** The local axes Meshes. */
  51384. private _localAxes;
  51385. /** If SkeletonViewer is enabled. */
  51386. private _isEnabled;
  51387. /** If SkeletonViewer is ready. */
  51388. private _ready;
  51389. /** SkeletonViewer render observable. */
  51390. private _obs;
  51391. /** The Utility Layer to render the gizmos in. */
  51392. private _utilityLayer;
  51393. private _boneIndices;
  51394. /** Gets the Scene. */
  51395. get scene(): Scene;
  51396. /** Gets the utilityLayer. */
  51397. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  51398. /** Checks Ready Status. */
  51399. get isReady(): Boolean;
  51400. /** Sets Ready Status. */
  51401. set ready(value: boolean);
  51402. /** Gets the debugMesh */
  51403. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  51404. /** Sets the debugMesh */
  51405. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  51406. /** Gets the displayMode */
  51407. get displayMode(): number;
  51408. /** Sets the displayMode */
  51409. set displayMode(value: number);
  51410. /**
  51411. * Creates a new SkeletonViewer
  51412. * @param skeleton defines the skeleton to render
  51413. * @param mesh defines the mesh attached to the skeleton
  51414. * @param scene defines the hosting scene
  51415. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  51416. * @param renderingGroupId defines the rendering group id to use with the viewer
  51417. * @param options All of the extra constructor options for the SkeletonViewer
  51418. */
  51419. constructor(
  51420. /** defines the skeleton to render */
  51421. skeleton: Skeleton,
  51422. /** defines the mesh attached to the skeleton */
  51423. mesh: AbstractMesh,
  51424. /** The Scene scope*/
  51425. scene: Scene,
  51426. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51427. autoUpdateBonesMatrices?: boolean,
  51428. /** defines the rendering group id to use with the viewer */
  51429. renderingGroupId?: number,
  51430. /** is the options for the viewer */
  51431. options?: Partial<ISkeletonViewerOptions>);
  51432. /** The Dynamic bindings for the update functions */
  51433. private _bindObs;
  51434. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  51435. update(): void;
  51436. /** Gets or sets a boolean indicating if the viewer is enabled */
  51437. set isEnabled(value: boolean);
  51438. get isEnabled(): boolean;
  51439. private _getBonePosition;
  51440. private _getLinesForBonesWithLength;
  51441. private _getLinesForBonesNoLength;
  51442. /** function to revert the mesh and scene back to the initial state. */
  51443. private _revert;
  51444. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  51445. private _getAbsoluteBindPoseToRef;
  51446. /** function to build and bind sphere joint points and spur bone representations. */
  51447. private _buildSpheresAndSpurs;
  51448. private _buildLocalAxes;
  51449. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  51450. private _displayLinesUpdate;
  51451. /** Changes the displayMode of the skeleton viewer
  51452. * @param mode The displayMode numerical value
  51453. */
  51454. changeDisplayMode(mode: number): void;
  51455. /** Sets a display option of the skeleton viewer
  51456. *
  51457. * | Option | Type | Default | Description |
  51458. * | --------------- | ------- | ------- | ----------- |
  51459. * | 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`. |
  51460. * | 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`. |
  51461. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  51462. * | 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`. |
  51463. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  51464. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  51465. *
  51466. * @param option String of the option name
  51467. * @param value The numerical option value
  51468. */
  51469. changeDisplayOptions(option: string, value: number): void;
  51470. /** Release associated resources */
  51471. dispose(): void;
  51472. }
  51473. }
  51474. declare module BABYLON {
  51475. /**
  51476. * Enum for Device Types
  51477. */
  51478. export enum DeviceType {
  51479. /** Generic */
  51480. Generic = 0,
  51481. /** Keyboard */
  51482. Keyboard = 1,
  51483. /** Mouse */
  51484. Mouse = 2,
  51485. /** Touch Pointers */
  51486. Touch = 3,
  51487. /** PS4 Dual Shock */
  51488. DualShock = 4,
  51489. /** Xbox */
  51490. Xbox = 5,
  51491. /** Switch Controller */
  51492. Switch = 6
  51493. }
  51494. /**
  51495. * Enum for All Pointers (Touch/Mouse)
  51496. */
  51497. export enum PointerInput {
  51498. /** Horizontal Axis */
  51499. Horizontal = 0,
  51500. /** Vertical Axis */
  51501. Vertical = 1,
  51502. /** Left Click or Touch */
  51503. LeftClick = 2,
  51504. /** Middle Click */
  51505. MiddleClick = 3,
  51506. /** Right Click */
  51507. RightClick = 4,
  51508. /** Browser Back */
  51509. BrowserBack = 5,
  51510. /** Browser Forward */
  51511. BrowserForward = 6
  51512. }
  51513. /**
  51514. * Enum for Dual Shock Gamepad
  51515. */
  51516. export enum DualShockInput {
  51517. /** Cross */
  51518. Cross = 0,
  51519. /** Circle */
  51520. Circle = 1,
  51521. /** Square */
  51522. Square = 2,
  51523. /** Triangle */
  51524. Triangle = 3,
  51525. /** L1 */
  51526. L1 = 4,
  51527. /** R1 */
  51528. R1 = 5,
  51529. /** L2 */
  51530. L2 = 6,
  51531. /** R2 */
  51532. R2 = 7,
  51533. /** Share */
  51534. Share = 8,
  51535. /** Options */
  51536. Options = 9,
  51537. /** L3 */
  51538. L3 = 10,
  51539. /** R3 */
  51540. R3 = 11,
  51541. /** DPadUp */
  51542. DPadUp = 12,
  51543. /** DPadDown */
  51544. DPadDown = 13,
  51545. /** DPadLeft */
  51546. DPadLeft = 14,
  51547. /** DRight */
  51548. DPadRight = 15,
  51549. /** Home */
  51550. Home = 16,
  51551. /** TouchPad */
  51552. TouchPad = 17,
  51553. /** LStickXAxis */
  51554. LStickXAxis = 18,
  51555. /** LStickYAxis */
  51556. LStickYAxis = 19,
  51557. /** RStickXAxis */
  51558. RStickXAxis = 20,
  51559. /** RStickYAxis */
  51560. RStickYAxis = 21
  51561. }
  51562. /**
  51563. * Enum for Xbox Gamepad
  51564. */
  51565. export enum XboxInput {
  51566. /** A */
  51567. A = 0,
  51568. /** B */
  51569. B = 1,
  51570. /** X */
  51571. X = 2,
  51572. /** Y */
  51573. Y = 3,
  51574. /** LB */
  51575. LB = 4,
  51576. /** RB */
  51577. RB = 5,
  51578. /** LT */
  51579. LT = 6,
  51580. /** RT */
  51581. RT = 7,
  51582. /** Back */
  51583. Back = 8,
  51584. /** Start */
  51585. Start = 9,
  51586. /** LS */
  51587. LS = 10,
  51588. /** RS */
  51589. RS = 11,
  51590. /** DPadUp */
  51591. DPadUp = 12,
  51592. /** DPadDown */
  51593. DPadDown = 13,
  51594. /** DPadLeft */
  51595. DPadLeft = 14,
  51596. /** DRight */
  51597. DPadRight = 15,
  51598. /** Home */
  51599. Home = 16,
  51600. /** LStickXAxis */
  51601. LStickXAxis = 17,
  51602. /** LStickYAxis */
  51603. LStickYAxis = 18,
  51604. /** RStickXAxis */
  51605. RStickXAxis = 19,
  51606. /** RStickYAxis */
  51607. RStickYAxis = 20
  51608. }
  51609. /**
  51610. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  51611. */
  51612. export enum SwitchInput {
  51613. /** B */
  51614. B = 0,
  51615. /** A */
  51616. A = 1,
  51617. /** Y */
  51618. Y = 2,
  51619. /** X */
  51620. X = 3,
  51621. /** L */
  51622. L = 4,
  51623. /** R */
  51624. R = 5,
  51625. /** ZL */
  51626. ZL = 6,
  51627. /** ZR */
  51628. ZR = 7,
  51629. /** Minus */
  51630. Minus = 8,
  51631. /** Plus */
  51632. Plus = 9,
  51633. /** LS */
  51634. LS = 10,
  51635. /** RS */
  51636. RS = 11,
  51637. /** DPadUp */
  51638. DPadUp = 12,
  51639. /** DPadDown */
  51640. DPadDown = 13,
  51641. /** DPadLeft */
  51642. DPadLeft = 14,
  51643. /** DRight */
  51644. DPadRight = 15,
  51645. /** Home */
  51646. Home = 16,
  51647. /** Capture */
  51648. Capture = 17,
  51649. /** LStickXAxis */
  51650. LStickXAxis = 18,
  51651. /** LStickYAxis */
  51652. LStickYAxis = 19,
  51653. /** RStickXAxis */
  51654. RStickXAxis = 20,
  51655. /** RStickYAxis */
  51656. RStickYAxis = 21
  51657. }
  51658. }
  51659. declare module BABYLON {
  51660. /**
  51661. * This class will take all inputs from Keyboard, Pointer, and
  51662. * any Gamepads and provide a polling system that all devices
  51663. * will use. This class assumes that there will only be one
  51664. * pointer device and one keyboard.
  51665. */
  51666. export class DeviceInputSystem implements IDisposable {
  51667. /**
  51668. * Callback to be triggered when a device is connected
  51669. */
  51670. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51671. /**
  51672. * Callback to be triggered when a device is disconnected
  51673. */
  51674. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51675. /**
  51676. * Callback to be triggered when event driven input is updated
  51677. */
  51678. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  51679. private _inputs;
  51680. private _gamepads;
  51681. private _keyboardActive;
  51682. private _pointerActive;
  51683. private _elementToAttachTo;
  51684. private _keyboardDownEvent;
  51685. private _keyboardUpEvent;
  51686. private _pointerMoveEvent;
  51687. private _pointerDownEvent;
  51688. private _pointerUpEvent;
  51689. private _gamepadConnectedEvent;
  51690. private _gamepadDisconnectedEvent;
  51691. private static _MAX_KEYCODES;
  51692. private static _MAX_POINTER_INPUTS;
  51693. private constructor();
  51694. /**
  51695. * Creates a new DeviceInputSystem instance
  51696. * @param engine Engine to pull input element from
  51697. * @returns The new instance
  51698. */
  51699. static Create(engine: Engine): DeviceInputSystem;
  51700. /**
  51701. * Checks for current device input value, given an id and input index
  51702. * @param deviceName Id of connected device
  51703. * @param inputIndex Index of device input
  51704. * @returns Current value of input
  51705. */
  51706. /**
  51707. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  51708. * @param deviceType Enum specifiying device type
  51709. * @param deviceSlot "Slot" or index that device is referenced in
  51710. * @param inputIndex Id of input to be checked
  51711. * @returns Current value of input
  51712. */
  51713. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  51714. /**
  51715. * Dispose of all the eventlisteners
  51716. */
  51717. dispose(): void;
  51718. /**
  51719. * Add device and inputs to device array
  51720. * @param deviceType Enum specifiying device type
  51721. * @param deviceSlot "Slot" or index that device is referenced in
  51722. * @param numberOfInputs Number of input entries to create for given device
  51723. */
  51724. private _registerDevice;
  51725. /**
  51726. * Given a specific device name, remove that device from the device map
  51727. * @param deviceType Enum specifiying device type
  51728. * @param deviceSlot "Slot" or index that device is referenced in
  51729. */
  51730. private _unregisterDevice;
  51731. /**
  51732. * Handle all actions that come from keyboard interaction
  51733. */
  51734. private _handleKeyActions;
  51735. /**
  51736. * Handle all actions that come from pointer interaction
  51737. */
  51738. private _handlePointerActions;
  51739. /**
  51740. * Handle all actions that come from gamepad interaction
  51741. */
  51742. private _handleGamepadActions;
  51743. /**
  51744. * Update all non-event based devices with each frame
  51745. * @param deviceType Enum specifiying device type
  51746. * @param deviceSlot "Slot" or index that device is referenced in
  51747. * @param inputIndex Id of input to be checked
  51748. */
  51749. private _updateDevice;
  51750. /**
  51751. * Gets DeviceType from the device name
  51752. * @param deviceName Name of Device from DeviceInputSystem
  51753. * @returns DeviceType enum value
  51754. */
  51755. private _getGamepadDeviceType;
  51756. }
  51757. }
  51758. declare module BABYLON {
  51759. /**
  51760. * Type to handle enforcement of inputs
  51761. */
  51762. 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;
  51763. }
  51764. declare module BABYLON {
  51765. /**
  51766. * Class that handles all input for a specific device
  51767. */
  51768. export class DeviceSource<T extends DeviceType> {
  51769. /** Type of device */
  51770. readonly deviceType: DeviceType;
  51771. /** "Slot" or index that device is referenced in */
  51772. readonly deviceSlot: number;
  51773. /**
  51774. * Observable to handle device input changes per device
  51775. */
  51776. readonly onInputChangedObservable: Observable<{
  51777. inputIndex: DeviceInput<T>;
  51778. previousState: Nullable<number>;
  51779. currentState: Nullable<number>;
  51780. }>;
  51781. private readonly _deviceInputSystem;
  51782. /**
  51783. * Default Constructor
  51784. * @param deviceInputSystem Reference to DeviceInputSystem
  51785. * @param deviceType Type of device
  51786. * @param deviceSlot "Slot" or index that device is referenced in
  51787. */
  51788. constructor(deviceInputSystem: DeviceInputSystem,
  51789. /** Type of device */
  51790. deviceType: DeviceType,
  51791. /** "Slot" or index that device is referenced in */
  51792. deviceSlot?: number);
  51793. /**
  51794. * Get input for specific input
  51795. * @param inputIndex index of specific input on device
  51796. * @returns Input value from DeviceInputSystem
  51797. */
  51798. getInput(inputIndex: DeviceInput<T>): number;
  51799. }
  51800. /**
  51801. * Class to keep track of devices
  51802. */
  51803. export class DeviceSourceManager implements IDisposable {
  51804. /**
  51805. * Observable to be triggered when before a device is connected
  51806. */
  51807. readonly onBeforeDeviceConnectedObservable: Observable<{
  51808. deviceType: DeviceType;
  51809. deviceSlot: number;
  51810. }>;
  51811. /**
  51812. * Observable to be triggered when before a device is disconnected
  51813. */
  51814. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  51815. deviceType: DeviceType;
  51816. deviceSlot: number;
  51817. }>;
  51818. /**
  51819. * Observable to be triggered when after a device is connected
  51820. */
  51821. readonly onAfterDeviceConnectedObservable: Observable<{
  51822. deviceType: DeviceType;
  51823. deviceSlot: number;
  51824. }>;
  51825. /**
  51826. * Observable to be triggered when after a device is disconnected
  51827. */
  51828. readonly onAfterDeviceDisconnectedObservable: Observable<{
  51829. deviceType: DeviceType;
  51830. deviceSlot: number;
  51831. }>;
  51832. private readonly _devices;
  51833. private readonly _firstDevice;
  51834. private readonly _deviceInputSystem;
  51835. /**
  51836. * Default Constructor
  51837. * @param engine engine to pull input element from
  51838. */
  51839. constructor(engine: Engine);
  51840. /**
  51841. * Gets a DeviceSource, given a type and slot
  51842. * @param deviceType Enum specifying device type
  51843. * @param deviceSlot "Slot" or index that device is referenced in
  51844. * @returns DeviceSource object
  51845. */
  51846. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  51847. /**
  51848. * Gets an array of DeviceSource objects for a given device type
  51849. * @param deviceType Enum specifying device type
  51850. * @returns Array of DeviceSource objects
  51851. */
  51852. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  51853. /**
  51854. * Dispose of DeviceInputSystem and other parts
  51855. */
  51856. dispose(): void;
  51857. /**
  51858. * Function to add device name to device list
  51859. * @param deviceType Enum specifying device type
  51860. * @param deviceSlot "Slot" or index that device is referenced in
  51861. */
  51862. private _addDevice;
  51863. /**
  51864. * Function to remove device name to device list
  51865. * @param deviceType Enum specifying device type
  51866. * @param deviceSlot "Slot" or index that device is referenced in
  51867. */
  51868. private _removeDevice;
  51869. /**
  51870. * Updates array storing first connected device of each type
  51871. * @param type Type of Device
  51872. */
  51873. private _updateFirstDevices;
  51874. }
  51875. }
  51876. declare module BABYLON {
  51877. /**
  51878. * Options to create the null engine
  51879. */
  51880. export class NullEngineOptions {
  51881. /**
  51882. * Render width (Default: 512)
  51883. */
  51884. renderWidth: number;
  51885. /**
  51886. * Render height (Default: 256)
  51887. */
  51888. renderHeight: number;
  51889. /**
  51890. * Texture size (Default: 512)
  51891. */
  51892. textureSize: number;
  51893. /**
  51894. * If delta time between frames should be constant
  51895. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51896. */
  51897. deterministicLockstep: boolean;
  51898. /**
  51899. * Maximum about of steps between frames (Default: 4)
  51900. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51901. */
  51902. lockstepMaxSteps: number;
  51903. /**
  51904. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  51905. */
  51906. useHighPrecisionMatrix?: boolean;
  51907. }
  51908. /**
  51909. * The null engine class provides support for headless version of babylon.js.
  51910. * This can be used in server side scenario or for testing purposes
  51911. */
  51912. export class NullEngine extends Engine {
  51913. private _options;
  51914. /**
  51915. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  51916. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51917. * @returns true if engine is in deterministic lock step mode
  51918. */
  51919. isDeterministicLockStep(): boolean;
  51920. /**
  51921. * Gets the max steps when engine is running in deterministic lock step
  51922. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51923. * @returns the max steps
  51924. */
  51925. getLockstepMaxSteps(): number;
  51926. /**
  51927. * Gets the current hardware scaling level.
  51928. * By default the hardware scaling level is computed from the window device ratio.
  51929. * 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.
  51930. * @returns a number indicating the current hardware scaling level
  51931. */
  51932. getHardwareScalingLevel(): number;
  51933. constructor(options?: NullEngineOptions);
  51934. /**
  51935. * Creates a vertex buffer
  51936. * @param vertices the data for the vertex buffer
  51937. * @returns the new WebGL static buffer
  51938. */
  51939. createVertexBuffer(vertices: FloatArray): DataBuffer;
  51940. /**
  51941. * Creates a new index buffer
  51942. * @param indices defines the content of the index buffer
  51943. * @param updatable defines if the index buffer must be updatable
  51944. * @returns a new webGL buffer
  51945. */
  51946. createIndexBuffer(indices: IndicesArray): DataBuffer;
  51947. /**
  51948. * Clear the current render buffer or the current render target (if any is set up)
  51949. * @param color defines the color to use
  51950. * @param backBuffer defines if the back buffer must be cleared
  51951. * @param depth defines if the depth buffer must be cleared
  51952. * @param stencil defines if the stencil buffer must be cleared
  51953. */
  51954. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51955. /**
  51956. * Gets the current render width
  51957. * @param useScreen defines if screen size must be used (or the current render target if any)
  51958. * @returns a number defining the current render width
  51959. */
  51960. getRenderWidth(useScreen?: boolean): number;
  51961. /**
  51962. * Gets the current render height
  51963. * @param useScreen defines if screen size must be used (or the current render target if any)
  51964. * @returns a number defining the current render height
  51965. */
  51966. getRenderHeight(useScreen?: boolean): number;
  51967. /**
  51968. * Set the WebGL's viewport
  51969. * @param viewport defines the viewport element to be used
  51970. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  51971. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  51972. */
  51973. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  51974. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  51975. /**
  51976. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  51977. * @param pipelineContext defines the pipeline context to use
  51978. * @param uniformsNames defines the list of uniform names
  51979. * @returns an array of webGL uniform locations
  51980. */
  51981. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  51982. /**
  51983. * Gets the lsit of active attributes for a given webGL program
  51984. * @param pipelineContext defines the pipeline context to use
  51985. * @param attributesNames defines the list of attribute names to get
  51986. * @returns an array of indices indicating the offset of each attribute
  51987. */
  51988. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  51989. /**
  51990. * Binds an effect to the webGL context
  51991. * @param effect defines the effect to bind
  51992. */
  51993. bindSamplers(effect: Effect): void;
  51994. /**
  51995. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  51996. * @param effect defines the effect to activate
  51997. */
  51998. enableEffect(effect: Effect): void;
  51999. /**
  52000. * Set various states to the webGL context
  52001. * @param culling defines backface culling state
  52002. * @param zOffset defines the value to apply to zOffset (0 by default)
  52003. * @param force defines if states must be applied even if cache is up to date
  52004. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  52005. */
  52006. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  52007. /**
  52008. * Set the value of an uniform to an array of int32
  52009. * @param uniform defines the webGL uniform location where to store the value
  52010. * @param array defines the array of int32 to store
  52011. * @returns true if value was set
  52012. */
  52013. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  52014. /**
  52015. * Set the value of an uniform to an array of int32 (stored as vec2)
  52016. * @param uniform defines the webGL uniform location where to store the value
  52017. * @param array defines the array of int32 to store
  52018. * @returns true if value was set
  52019. */
  52020. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  52021. /**
  52022. * Set the value of an uniform to an array of int32 (stored as vec3)
  52023. * @param uniform defines the webGL uniform location where to store the value
  52024. * @param array defines the array of int32 to store
  52025. * @returns true if value was set
  52026. */
  52027. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  52028. /**
  52029. * Set the value of an uniform to an array of int32 (stored as vec4)
  52030. * @param uniform defines the webGL uniform location where to store the value
  52031. * @param array defines the array of int32 to store
  52032. * @returns true if value was set
  52033. */
  52034. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  52035. /**
  52036. * Set the value of an uniform to an array of float32
  52037. * @param uniform defines the webGL uniform location where to store the value
  52038. * @param array defines the array of float32 to store
  52039. * @returns true if value was set
  52040. */
  52041. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  52042. /**
  52043. * Set the value of an uniform to an array of float32 (stored as vec2)
  52044. * @param uniform defines the webGL uniform location where to store the value
  52045. * @param array defines the array of float32 to store
  52046. * @returns true if value was set
  52047. */
  52048. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  52049. /**
  52050. * Set the value of an uniform to an array of float32 (stored as vec3)
  52051. * @param uniform defines the webGL uniform location where to store the value
  52052. * @param array defines the array of float32 to store
  52053. * @returns true if value was set
  52054. */
  52055. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  52056. /**
  52057. * Set the value of an uniform to an array of float32 (stored as vec4)
  52058. * @param uniform defines the webGL uniform location where to store the value
  52059. * @param array defines the array of float32 to store
  52060. * @returns true if value was set
  52061. */
  52062. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  52063. /**
  52064. * Set the value of an uniform to an array of number
  52065. * @param uniform defines the webGL uniform location where to store the value
  52066. * @param array defines the array of number to store
  52067. * @returns true if value was set
  52068. */
  52069. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  52070. /**
  52071. * Set the value of an uniform to an array of number (stored as vec2)
  52072. * @param uniform defines the webGL uniform location where to store the value
  52073. * @param array defines the array of number to store
  52074. * @returns true if value was set
  52075. */
  52076. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  52077. /**
  52078. * Set the value of an uniform to an array of number (stored as vec3)
  52079. * @param uniform defines the webGL uniform location where to store the value
  52080. * @param array defines the array of number to store
  52081. * @returns true if value was set
  52082. */
  52083. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  52084. /**
  52085. * Set the value of an uniform to an array of number (stored as vec4)
  52086. * @param uniform defines the webGL uniform location where to store the value
  52087. * @param array defines the array of number to store
  52088. * @returns true if value was set
  52089. */
  52090. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  52091. /**
  52092. * Set the value of an uniform to an array of float32 (stored as matrices)
  52093. * @param uniform defines the webGL uniform location where to store the value
  52094. * @param matrices defines the array of float32 to store
  52095. * @returns true if value was set
  52096. */
  52097. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  52098. /**
  52099. * Set the value of an uniform to a matrix (3x3)
  52100. * @param uniform defines the webGL uniform location where to store the value
  52101. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  52102. * @returns true if value was set
  52103. */
  52104. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  52105. /**
  52106. * Set the value of an uniform to a matrix (2x2)
  52107. * @param uniform defines the webGL uniform location where to store the value
  52108. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  52109. * @returns true if value was set
  52110. */
  52111. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  52112. /**
  52113. * Set the value of an uniform to a number (float)
  52114. * @param uniform defines the webGL uniform location where to store the value
  52115. * @param value defines the float number to store
  52116. * @returns true if value was set
  52117. */
  52118. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  52119. /**
  52120. * Set the value of an uniform to a vec2
  52121. * @param uniform defines the webGL uniform location where to store the value
  52122. * @param x defines the 1st component of the value
  52123. * @param y defines the 2nd component of the value
  52124. * @returns true if value was set
  52125. */
  52126. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  52127. /**
  52128. * Set the value of an uniform to a vec3
  52129. * @param uniform defines the webGL uniform location where to store the value
  52130. * @param x defines the 1st component of the value
  52131. * @param y defines the 2nd component of the value
  52132. * @param z defines the 3rd component of the value
  52133. * @returns true if value was set
  52134. */
  52135. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  52136. /**
  52137. * Set the value of an uniform to a boolean
  52138. * @param uniform defines the webGL uniform location where to store the value
  52139. * @param bool defines the boolean to store
  52140. * @returns true if value was set
  52141. */
  52142. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  52143. /**
  52144. * Set the value of an uniform to a vec4
  52145. * @param uniform defines the webGL uniform location where to store the value
  52146. * @param x defines the 1st component of the value
  52147. * @param y defines the 2nd component of the value
  52148. * @param z defines the 3rd component of the value
  52149. * @param w defines the 4th component of the value
  52150. * @returns true if value was set
  52151. */
  52152. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  52153. /**
  52154. * Sets the current alpha mode
  52155. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  52156. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  52157. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52158. */
  52159. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  52160. /**
  52161. * Bind webGl buffers directly to the webGL context
  52162. * @param vertexBuffers defines the vertex buffer to bind
  52163. * @param indexBuffer defines the index buffer to bind
  52164. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  52165. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  52166. * @param effect defines the effect associated with the vertex buffer
  52167. */
  52168. bindBuffers(vertexBuffers: {
  52169. [key: string]: VertexBuffer;
  52170. }, indexBuffer: DataBuffer, effect: Effect): void;
  52171. /**
  52172. * Force the entire cache to be cleared
  52173. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  52174. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  52175. */
  52176. wipeCaches(bruteForce?: boolean): void;
  52177. /**
  52178. * Send a draw order
  52179. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  52180. * @param indexStart defines the starting index
  52181. * @param indexCount defines the number of index to draw
  52182. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52183. */
  52184. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  52185. /**
  52186. * Draw a list of indexed primitives
  52187. * @param fillMode defines the primitive to use
  52188. * @param indexStart defines the starting index
  52189. * @param indexCount defines the number of index to draw
  52190. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52191. */
  52192. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52193. /**
  52194. * Draw a list of unindexed primitives
  52195. * @param fillMode defines the primitive to use
  52196. * @param verticesStart defines the index of first vertex to draw
  52197. * @param verticesCount defines the count of vertices to draw
  52198. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52199. */
  52200. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52201. /** @hidden */
  52202. _createTexture(): WebGLTexture;
  52203. /** @hidden */
  52204. _releaseTexture(texture: InternalTexture): void;
  52205. /**
  52206. * Usually called from Texture.ts.
  52207. * Passed information to create a WebGLTexture
  52208. * @param urlArg defines a value which contains one of the following:
  52209. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  52210. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  52211. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  52212. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  52213. * @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)
  52214. * @param scene needed for loading to the correct scene
  52215. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  52216. * @param onLoad optional callback to be called upon successful completion
  52217. * @param onError optional callback to be called upon failure
  52218. * @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
  52219. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  52220. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  52221. * @param forcedExtension defines the extension to use to pick the right loader
  52222. * @param mimeType defines an optional mime type
  52223. * @returns a InternalTexture for assignment back into BABYLON.Texture
  52224. */
  52225. 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;
  52226. /**
  52227. * Creates a new render target texture
  52228. * @param size defines the size of the texture
  52229. * @param options defines the options used to create the texture
  52230. * @returns a new render target texture stored in an InternalTexture
  52231. */
  52232. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  52233. /**
  52234. * Update the sampling mode of a given texture
  52235. * @param samplingMode defines the required sampling mode
  52236. * @param texture defines the texture to update
  52237. */
  52238. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  52239. /**
  52240. * Binds the frame buffer to the specified texture.
  52241. * @param texture The texture to render to or null for the default canvas
  52242. * @param faceIndex The face of the texture to render to in case of cube texture
  52243. * @param requiredWidth The width of the target to render to
  52244. * @param requiredHeight The height of the target to render to
  52245. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  52246. * @param lodLevel defines le lod level to bind to the frame buffer
  52247. */
  52248. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  52249. /**
  52250. * Unbind the current render target texture from the webGL context
  52251. * @param texture defines the render target texture to unbind
  52252. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  52253. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  52254. */
  52255. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  52256. /**
  52257. * Creates a dynamic vertex buffer
  52258. * @param vertices the data for the dynamic vertex buffer
  52259. * @returns the new WebGL dynamic buffer
  52260. */
  52261. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  52262. /**
  52263. * Update the content of a dynamic texture
  52264. * @param texture defines the texture to update
  52265. * @param canvas defines the canvas containing the source
  52266. * @param invertY defines if data must be stored with Y axis inverted
  52267. * @param premulAlpha defines if alpha is stored as premultiplied
  52268. * @param format defines the format of the data
  52269. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  52270. */
  52271. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  52272. /**
  52273. * Gets a boolean indicating if all created effects are ready
  52274. * @returns true if all effects are ready
  52275. */
  52276. areAllEffectsReady(): boolean;
  52277. /**
  52278. * @hidden
  52279. * Get the current error code of the webGL context
  52280. * @returns the error code
  52281. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  52282. */
  52283. getError(): number;
  52284. /** @hidden */
  52285. _getUnpackAlignement(): number;
  52286. /** @hidden */
  52287. _unpackFlipY(value: boolean): void;
  52288. /**
  52289. * Update a dynamic index buffer
  52290. * @param indexBuffer defines the target index buffer
  52291. * @param indices defines the data to update
  52292. * @param offset defines the offset in the target index buffer where update should start
  52293. */
  52294. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  52295. /**
  52296. * Updates a dynamic vertex buffer.
  52297. * @param vertexBuffer the vertex buffer to update
  52298. * @param vertices the data used to update the vertex buffer
  52299. * @param byteOffset the byte offset of the data (optional)
  52300. * @param byteLength the byte length of the data (optional)
  52301. */
  52302. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  52303. /** @hidden */
  52304. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  52305. /** @hidden */
  52306. _bindTexture(channel: number, texture: InternalTexture): void;
  52307. protected _deleteBuffer(buffer: WebGLBuffer): void;
  52308. /**
  52309. * 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
  52310. */
  52311. releaseEffects(): void;
  52312. displayLoadingUI(): void;
  52313. hideLoadingUI(): void;
  52314. /** @hidden */
  52315. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52316. /** @hidden */
  52317. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52318. /** @hidden */
  52319. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52320. /** @hidden */
  52321. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  52322. }
  52323. }
  52324. declare module BABYLON {
  52325. /**
  52326. * @hidden
  52327. **/
  52328. export class _TimeToken {
  52329. _startTimeQuery: Nullable<WebGLQuery>;
  52330. _endTimeQuery: Nullable<WebGLQuery>;
  52331. _timeElapsedQuery: Nullable<WebGLQuery>;
  52332. _timeElapsedQueryEnded: boolean;
  52333. }
  52334. }
  52335. declare module BABYLON {
  52336. /** @hidden */
  52337. export class _OcclusionDataStorage {
  52338. /** @hidden */
  52339. occlusionInternalRetryCounter: number;
  52340. /** @hidden */
  52341. isOcclusionQueryInProgress: boolean;
  52342. /** @hidden */
  52343. isOccluded: boolean;
  52344. /** @hidden */
  52345. occlusionRetryCount: number;
  52346. /** @hidden */
  52347. occlusionType: number;
  52348. /** @hidden */
  52349. occlusionQueryAlgorithmType: number;
  52350. }
  52351. interface Engine {
  52352. /**
  52353. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  52354. * @return the new query
  52355. */
  52356. createQuery(): WebGLQuery;
  52357. /**
  52358. * Delete and release a webGL query
  52359. * @param query defines the query to delete
  52360. * @return the current engine
  52361. */
  52362. deleteQuery(query: WebGLQuery): Engine;
  52363. /**
  52364. * Check if a given query has resolved and got its value
  52365. * @param query defines the query to check
  52366. * @returns true if the query got its value
  52367. */
  52368. isQueryResultAvailable(query: WebGLQuery): boolean;
  52369. /**
  52370. * Gets the value of a given query
  52371. * @param query defines the query to check
  52372. * @returns the value of the query
  52373. */
  52374. getQueryResult(query: WebGLQuery): number;
  52375. /**
  52376. * Initiates an occlusion query
  52377. * @param algorithmType defines the algorithm to use
  52378. * @param query defines the query to use
  52379. * @returns the current engine
  52380. * @see https://doc.babylonjs.com/features/occlusionquery
  52381. */
  52382. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  52383. /**
  52384. * Ends an occlusion query
  52385. * @see https://doc.babylonjs.com/features/occlusionquery
  52386. * @param algorithmType defines the algorithm to use
  52387. * @returns the current engine
  52388. */
  52389. endOcclusionQuery(algorithmType: number): Engine;
  52390. /**
  52391. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  52392. * Please note that only one query can be issued at a time
  52393. * @returns a time token used to track the time span
  52394. */
  52395. startTimeQuery(): Nullable<_TimeToken>;
  52396. /**
  52397. * Ends a time query
  52398. * @param token defines the token used to measure the time span
  52399. * @returns the time spent (in ns)
  52400. */
  52401. endTimeQuery(token: _TimeToken): int;
  52402. /** @hidden */
  52403. _currentNonTimestampToken: Nullable<_TimeToken>;
  52404. /** @hidden */
  52405. _createTimeQuery(): WebGLQuery;
  52406. /** @hidden */
  52407. _deleteTimeQuery(query: WebGLQuery): void;
  52408. /** @hidden */
  52409. _getGlAlgorithmType(algorithmType: number): number;
  52410. /** @hidden */
  52411. _getTimeQueryResult(query: WebGLQuery): any;
  52412. /** @hidden */
  52413. _getTimeQueryAvailability(query: WebGLQuery): any;
  52414. }
  52415. interface AbstractMesh {
  52416. /**
  52417. * Backing filed
  52418. * @hidden
  52419. */
  52420. __occlusionDataStorage: _OcclusionDataStorage;
  52421. /**
  52422. * Access property
  52423. * @hidden
  52424. */
  52425. _occlusionDataStorage: _OcclusionDataStorage;
  52426. /**
  52427. * 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.
  52428. * The default value is -1 which means don't break the query and wait till the result
  52429. * @see https://doc.babylonjs.com/features/occlusionquery
  52430. */
  52431. occlusionRetryCount: number;
  52432. /**
  52433. * 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:
  52434. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  52435. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  52436. * * 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.
  52437. * @see https://doc.babylonjs.com/features/occlusionquery
  52438. */
  52439. occlusionType: number;
  52440. /**
  52441. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  52442. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  52443. * * 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.
  52444. * @see https://doc.babylonjs.com/features/occlusionquery
  52445. */
  52446. occlusionQueryAlgorithmType: number;
  52447. /**
  52448. * 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
  52449. * @see https://doc.babylonjs.com/features/occlusionquery
  52450. */
  52451. isOccluded: boolean;
  52452. /**
  52453. * Flag to check the progress status of the query
  52454. * @see https://doc.babylonjs.com/features/occlusionquery
  52455. */
  52456. isOcclusionQueryInProgress: boolean;
  52457. }
  52458. }
  52459. declare module BABYLON {
  52460. /** @hidden */
  52461. export var _forceTransformFeedbackToBundle: boolean;
  52462. interface Engine {
  52463. /**
  52464. * Creates a webGL transform feedback object
  52465. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  52466. * @returns the webGL transform feedback object
  52467. */
  52468. createTransformFeedback(): WebGLTransformFeedback;
  52469. /**
  52470. * Delete a webGL transform feedback object
  52471. * @param value defines the webGL transform feedback object to delete
  52472. */
  52473. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  52474. /**
  52475. * Bind a webGL transform feedback object to the webgl context
  52476. * @param value defines the webGL transform feedback object to bind
  52477. */
  52478. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  52479. /**
  52480. * Begins a transform feedback operation
  52481. * @param usePoints defines if points or triangles must be used
  52482. */
  52483. beginTransformFeedback(usePoints: boolean): void;
  52484. /**
  52485. * Ends a transform feedback operation
  52486. */
  52487. endTransformFeedback(): void;
  52488. /**
  52489. * Specify the varyings to use with transform feedback
  52490. * @param program defines the associated webGL program
  52491. * @param value defines the list of strings representing the varying names
  52492. */
  52493. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  52494. /**
  52495. * Bind a webGL buffer for a transform feedback operation
  52496. * @param value defines the webGL buffer to bind
  52497. */
  52498. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  52499. }
  52500. }
  52501. declare module BABYLON {
  52502. /**
  52503. * Class used to define an additional view for the engine
  52504. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52505. */
  52506. export class EngineView {
  52507. /** Defines the canvas where to render the view */
  52508. target: HTMLCanvasElement;
  52509. /** Defines an optional camera used to render the view (will use active camera else) */
  52510. camera?: Camera;
  52511. }
  52512. interface Engine {
  52513. /**
  52514. * Gets or sets the HTML element to use for attaching events
  52515. */
  52516. inputElement: Nullable<HTMLElement>;
  52517. /**
  52518. * Gets the current engine view
  52519. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52520. */
  52521. activeView: Nullable<EngineView>;
  52522. /** Gets or sets the list of views */
  52523. views: EngineView[];
  52524. /**
  52525. * Register a new child canvas
  52526. * @param canvas defines the canvas to register
  52527. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  52528. * @returns the associated view
  52529. */
  52530. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  52531. /**
  52532. * Remove a registered child canvas
  52533. * @param canvas defines the canvas to remove
  52534. * @returns the current engine
  52535. */
  52536. unRegisterView(canvas: HTMLCanvasElement): Engine;
  52537. }
  52538. }
  52539. declare module BABYLON {
  52540. interface Engine {
  52541. /** @hidden */
  52542. _excludedCompressedTextures: string[];
  52543. /** @hidden */
  52544. _textureFormatInUse: string;
  52545. /**
  52546. * Gets the list of texture formats supported
  52547. */
  52548. readonly texturesSupported: Array<string>;
  52549. /**
  52550. * Gets the texture format in use
  52551. */
  52552. readonly textureFormatInUse: Nullable<string>;
  52553. /**
  52554. * Set the compressed texture extensions or file names to skip.
  52555. *
  52556. * @param skippedFiles defines the list of those texture files you want to skip
  52557. * Example: [".dds", ".env", "myfile.png"]
  52558. */
  52559. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  52560. /**
  52561. * Set the compressed texture format to use, based on the formats you have, and the formats
  52562. * supported by the hardware / browser.
  52563. *
  52564. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  52565. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  52566. * to API arguments needed to compressed textures. This puts the burden on the container
  52567. * generator to house the arcane code for determining these for current & future formats.
  52568. *
  52569. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52570. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52571. *
  52572. * Note: The result of this call is not taken into account when a texture is base64.
  52573. *
  52574. * @param formatsAvailable defines the list of those format families you have created
  52575. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  52576. *
  52577. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  52578. * @returns The extension selected.
  52579. */
  52580. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  52581. }
  52582. }
  52583. declare module BABYLON {
  52584. /**
  52585. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  52586. */
  52587. export interface CubeMapInfo {
  52588. /**
  52589. * The pixel array for the front face.
  52590. * This is stored in format, left to right, up to down format.
  52591. */
  52592. front: Nullable<ArrayBufferView>;
  52593. /**
  52594. * The pixel array for the back face.
  52595. * This is stored in format, left to right, up to down format.
  52596. */
  52597. back: Nullable<ArrayBufferView>;
  52598. /**
  52599. * The pixel array for the left face.
  52600. * This is stored in format, left to right, up to down format.
  52601. */
  52602. left: Nullable<ArrayBufferView>;
  52603. /**
  52604. * The pixel array for the right face.
  52605. * This is stored in format, left to right, up to down format.
  52606. */
  52607. right: Nullable<ArrayBufferView>;
  52608. /**
  52609. * The pixel array for the up face.
  52610. * This is stored in format, left to right, up to down format.
  52611. */
  52612. up: Nullable<ArrayBufferView>;
  52613. /**
  52614. * The pixel array for the down face.
  52615. * This is stored in format, left to right, up to down format.
  52616. */
  52617. down: Nullable<ArrayBufferView>;
  52618. /**
  52619. * The size of the cubemap stored.
  52620. *
  52621. * Each faces will be size * size pixels.
  52622. */
  52623. size: number;
  52624. /**
  52625. * The format of the texture.
  52626. *
  52627. * RGBA, RGB.
  52628. */
  52629. format: number;
  52630. /**
  52631. * The type of the texture data.
  52632. *
  52633. * UNSIGNED_INT, FLOAT.
  52634. */
  52635. type: number;
  52636. /**
  52637. * Specifies whether the texture is in gamma space.
  52638. */
  52639. gammaSpace: boolean;
  52640. }
  52641. /**
  52642. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  52643. */
  52644. export class PanoramaToCubeMapTools {
  52645. private static FACE_LEFT;
  52646. private static FACE_RIGHT;
  52647. private static FACE_FRONT;
  52648. private static FACE_BACK;
  52649. private static FACE_DOWN;
  52650. private static FACE_UP;
  52651. /**
  52652. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  52653. *
  52654. * @param float32Array The source data.
  52655. * @param inputWidth The width of the input panorama.
  52656. * @param inputHeight The height of the input panorama.
  52657. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  52658. * @return The cubemap data
  52659. */
  52660. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  52661. private static CreateCubemapTexture;
  52662. private static CalcProjectionSpherical;
  52663. }
  52664. }
  52665. declare module BABYLON {
  52666. /**
  52667. * Helper class dealing with the extraction of spherical polynomial dataArray
  52668. * from a cube map.
  52669. */
  52670. export class CubeMapToSphericalPolynomialTools {
  52671. private static FileFaces;
  52672. /**
  52673. * Converts a texture to the according Spherical Polynomial data.
  52674. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52675. *
  52676. * @param texture The texture to extract the information from.
  52677. * @return The Spherical Polynomial data.
  52678. */
  52679. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  52680. /**
  52681. * Converts a cubemap to the according Spherical Polynomial data.
  52682. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52683. *
  52684. * @param cubeInfo The Cube map to extract the information from.
  52685. * @return The Spherical Polynomial data.
  52686. */
  52687. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  52688. }
  52689. }
  52690. declare module BABYLON {
  52691. interface BaseTexture {
  52692. /**
  52693. * Get the polynomial representation of the texture data.
  52694. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  52695. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  52696. */
  52697. sphericalPolynomial: Nullable<SphericalPolynomial>;
  52698. }
  52699. }
  52700. declare module BABYLON {
  52701. /** @hidden */
  52702. export var rgbdEncodePixelShader: {
  52703. name: string;
  52704. shader: string;
  52705. };
  52706. }
  52707. declare module BABYLON {
  52708. /** @hidden */
  52709. export var rgbdDecodePixelShader: {
  52710. name: string;
  52711. shader: string;
  52712. };
  52713. }
  52714. declare module BABYLON {
  52715. /**
  52716. * Raw texture data and descriptor sufficient for WebGL texture upload
  52717. */
  52718. export interface EnvironmentTextureInfo {
  52719. /**
  52720. * Version of the environment map
  52721. */
  52722. version: number;
  52723. /**
  52724. * Width of image
  52725. */
  52726. width: number;
  52727. /**
  52728. * Irradiance information stored in the file.
  52729. */
  52730. irradiance: any;
  52731. /**
  52732. * Specular information stored in the file.
  52733. */
  52734. specular: any;
  52735. }
  52736. /**
  52737. * Defines One Image in the file. It requires only the position in the file
  52738. * as well as the length.
  52739. */
  52740. interface BufferImageData {
  52741. /**
  52742. * Length of the image data.
  52743. */
  52744. length: number;
  52745. /**
  52746. * Position of the data from the null terminator delimiting the end of the JSON.
  52747. */
  52748. position: number;
  52749. }
  52750. /**
  52751. * Defines the specular data enclosed in the file.
  52752. * This corresponds to the version 1 of the data.
  52753. */
  52754. export interface EnvironmentTextureSpecularInfoV1 {
  52755. /**
  52756. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  52757. */
  52758. specularDataPosition?: number;
  52759. /**
  52760. * This contains all the images data needed to reconstruct the cubemap.
  52761. */
  52762. mipmaps: Array<BufferImageData>;
  52763. /**
  52764. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  52765. */
  52766. lodGenerationScale: number;
  52767. }
  52768. /**
  52769. * Sets of helpers addressing the serialization and deserialization of environment texture
  52770. * stored in a BabylonJS env file.
  52771. * Those files are usually stored as .env files.
  52772. */
  52773. export class EnvironmentTextureTools {
  52774. /**
  52775. * Magic number identifying the env file.
  52776. */
  52777. private static _MagicBytes;
  52778. /**
  52779. * Gets the environment info from an env file.
  52780. * @param data The array buffer containing the .env bytes.
  52781. * @returns the environment file info (the json header) if successfully parsed.
  52782. */
  52783. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  52784. /**
  52785. * Creates an environment texture from a loaded cube texture.
  52786. * @param texture defines the cube texture to convert in env file
  52787. * @return a promise containing the environment data if succesfull.
  52788. */
  52789. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  52790. /**
  52791. * Creates a JSON representation of the spherical data.
  52792. * @param texture defines the texture containing the polynomials
  52793. * @return the JSON representation of the spherical info
  52794. */
  52795. private static _CreateEnvTextureIrradiance;
  52796. /**
  52797. * Creates the ArrayBufferViews used for initializing environment texture image data.
  52798. * @param data the image data
  52799. * @param info parameters that determine what views will be created for accessing the underlying buffer
  52800. * @return the views described by info providing access to the underlying buffer
  52801. */
  52802. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  52803. /**
  52804. * Uploads the texture info contained in the env file to the GPU.
  52805. * @param texture defines the internal texture to upload to
  52806. * @param data defines the data to load
  52807. * @param info defines the texture info retrieved through the GetEnvInfo method
  52808. * @returns a promise
  52809. */
  52810. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  52811. private static _OnImageReadyAsync;
  52812. /**
  52813. * Uploads the levels of image data to the GPU.
  52814. * @param texture defines the internal texture to upload to
  52815. * @param imageData defines the array buffer views of image data [mipmap][face]
  52816. * @returns a promise
  52817. */
  52818. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  52819. /**
  52820. * Uploads spherical polynomials information to the texture.
  52821. * @param texture defines the texture we are trying to upload the information to
  52822. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  52823. */
  52824. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  52825. /** @hidden */
  52826. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52827. }
  52828. }
  52829. declare module BABYLON {
  52830. /**
  52831. * Class used to inline functions in shader code
  52832. */
  52833. export class ShaderCodeInliner {
  52834. private static readonly _RegexpFindFunctionNameAndType;
  52835. private _sourceCode;
  52836. private _functionDescr;
  52837. private _numMaxIterations;
  52838. /** Gets or sets the token used to mark the functions to inline */
  52839. inlineToken: string;
  52840. /** Gets or sets the debug mode */
  52841. debug: boolean;
  52842. /** Gets the code after the inlining process */
  52843. get code(): string;
  52844. /**
  52845. * Initializes the inliner
  52846. * @param sourceCode shader code source to inline
  52847. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  52848. */
  52849. constructor(sourceCode: string, numMaxIterations?: number);
  52850. /**
  52851. * Start the processing of the shader code
  52852. */
  52853. processCode(): void;
  52854. private _collectFunctions;
  52855. private _processInlining;
  52856. private _extractBetweenMarkers;
  52857. private _skipWhitespaces;
  52858. private _removeComments;
  52859. private _replaceFunctionCallsByCode;
  52860. private _findBackward;
  52861. private _escapeRegExp;
  52862. private _replaceNames;
  52863. }
  52864. }
  52865. declare module BABYLON {
  52866. /**
  52867. * Container for accessors for natively-stored mesh data buffers.
  52868. */
  52869. class NativeDataBuffer extends DataBuffer {
  52870. /**
  52871. * Accessor value used to identify/retrieve a natively-stored index buffer.
  52872. */
  52873. nativeIndexBuffer?: any;
  52874. /**
  52875. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  52876. */
  52877. nativeVertexBuffer?: any;
  52878. }
  52879. /** @hidden */
  52880. class NativeTexture extends InternalTexture {
  52881. getInternalTexture(): InternalTexture;
  52882. getViewCount(): number;
  52883. }
  52884. /** @hidden */
  52885. export class NativeEngine extends Engine {
  52886. private readonly _native;
  52887. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  52888. private readonly INVALID_HANDLE;
  52889. private _boundBuffersVertexArray;
  52890. private _currentDepthTest;
  52891. getHardwareScalingLevel(): number;
  52892. constructor();
  52893. dispose(): void;
  52894. /**
  52895. * Can be used to override the current requestAnimationFrame requester.
  52896. * @hidden
  52897. */
  52898. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  52899. /**
  52900. * Override default engine behavior.
  52901. * @param color
  52902. * @param backBuffer
  52903. * @param depth
  52904. * @param stencil
  52905. */
  52906. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  52907. /**
  52908. * Gets host document
  52909. * @returns the host document object
  52910. */
  52911. getHostDocument(): Nullable<Document>;
  52912. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  52913. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  52914. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  52915. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  52916. [key: string]: VertexBuffer;
  52917. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  52918. bindBuffers(vertexBuffers: {
  52919. [key: string]: VertexBuffer;
  52920. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  52921. recordVertexArrayObject(vertexBuffers: {
  52922. [key: string]: VertexBuffer;
  52923. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  52924. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  52925. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  52926. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  52927. /**
  52928. * Draw a list of indexed primitives
  52929. * @param fillMode defines the primitive to use
  52930. * @param indexStart defines the starting index
  52931. * @param indexCount defines the number of index to draw
  52932. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52933. */
  52934. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52935. /**
  52936. * Draw a list of unindexed primitives
  52937. * @param fillMode defines the primitive to use
  52938. * @param verticesStart defines the index of first vertex to draw
  52939. * @param verticesCount defines the count of vertices to draw
  52940. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52941. */
  52942. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52943. createPipelineContext(): IPipelineContext;
  52944. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  52945. /** @hidden */
  52946. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  52947. /** @hidden */
  52948. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  52949. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  52950. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  52951. protected _setProgram(program: WebGLProgram): void;
  52952. _releaseEffect(effect: Effect): void;
  52953. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  52954. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  52955. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  52956. bindSamplers(effect: Effect): void;
  52957. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  52958. getRenderWidth(useScreen?: boolean): number;
  52959. getRenderHeight(useScreen?: boolean): number;
  52960. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  52961. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  52962. /**
  52963. * Set the z offset to apply to current rendering
  52964. * @param value defines the offset to apply
  52965. */
  52966. setZOffset(value: number): void;
  52967. /**
  52968. * Gets the current value of the zOffset
  52969. * @returns the current zOffset state
  52970. */
  52971. getZOffset(): number;
  52972. /**
  52973. * Enable or disable depth buffering
  52974. * @param enable defines the state to set
  52975. */
  52976. setDepthBuffer(enable: boolean): void;
  52977. /**
  52978. * Gets a boolean indicating if depth writing is enabled
  52979. * @returns the current depth writing state
  52980. */
  52981. getDepthWrite(): boolean;
  52982. setDepthFunctionToGreater(): void;
  52983. setDepthFunctionToGreaterOrEqual(): void;
  52984. setDepthFunctionToLess(): void;
  52985. setDepthFunctionToLessOrEqual(): void;
  52986. /**
  52987. * Enable or disable depth writing
  52988. * @param enable defines the state to set
  52989. */
  52990. setDepthWrite(enable: boolean): void;
  52991. /**
  52992. * Enable or disable color writing
  52993. * @param enable defines the state to set
  52994. */
  52995. setColorWrite(enable: boolean): void;
  52996. /**
  52997. * Gets a boolean indicating if color writing is enabled
  52998. * @returns the current color writing state
  52999. */
  53000. getColorWrite(): boolean;
  53001. /**
  53002. * Sets alpha constants used by some alpha blending modes
  53003. * @param r defines the red component
  53004. * @param g defines the green component
  53005. * @param b defines the blue component
  53006. * @param a defines the alpha component
  53007. */
  53008. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  53009. /**
  53010. * Sets the current alpha mode
  53011. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  53012. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  53013. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53014. */
  53015. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  53016. /**
  53017. * Gets the current alpha mode
  53018. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53019. * @returns the current alpha mode
  53020. */
  53021. getAlphaMode(): number;
  53022. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  53023. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  53024. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  53025. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  53026. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  53027. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  53028. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  53029. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  53030. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  53031. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  53032. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  53033. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  53034. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  53035. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  53036. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  53037. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  53038. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  53039. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  53040. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  53041. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  53042. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  53043. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  53044. wipeCaches(bruteForce?: boolean): void;
  53045. _createTexture(): WebGLTexture;
  53046. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  53047. /**
  53048. * Usually called from Texture.ts.
  53049. * Passed information to create a WebGLTexture
  53050. * @param url defines a value which contains one of the following:
  53051. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  53052. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  53053. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  53054. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  53055. * @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)
  53056. * @param scene needed for loading to the correct scene
  53057. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  53058. * @param onLoad optional callback to be called upon successful completion
  53059. * @param onError optional callback to be called upon failure
  53060. * @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
  53061. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  53062. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  53063. * @param forcedExtension defines the extension to use to pick the right loader
  53064. * @param mimeType defines an optional mime type
  53065. * @returns a InternalTexture for assignment back into BABYLON.Texture
  53066. */
  53067. 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;
  53068. /**
  53069. * Creates a cube texture
  53070. * @param rootUrl defines the url where the files to load is located
  53071. * @param scene defines the current scene
  53072. * @param files defines the list of files to load (1 per face)
  53073. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  53074. * @param onLoad defines an optional callback raised when the texture is loaded
  53075. * @param onError defines an optional callback raised if there is an issue to load the texture
  53076. * @param format defines the format of the data
  53077. * @param forcedExtension defines the extension to use to pick the right loader
  53078. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  53079. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  53080. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  53081. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  53082. * @returns the cube texture as an InternalTexture
  53083. */
  53084. 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;
  53085. private _getSamplingFilter;
  53086. private static _GetNativeTextureFormat;
  53087. createRenderTargetTexture(size: number | {
  53088. width: number;
  53089. height: number;
  53090. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  53091. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  53092. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  53093. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  53094. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  53095. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  53096. /**
  53097. * Updates a dynamic vertex buffer.
  53098. * @param vertexBuffer the vertex buffer to update
  53099. * @param data the data used to update the vertex buffer
  53100. * @param byteOffset the byte offset of the data (optional)
  53101. * @param byteLength the byte length of the data (optional)
  53102. */
  53103. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  53104. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  53105. private _updateAnisotropicLevel;
  53106. private _getAddressMode;
  53107. /** @hidden */
  53108. _bindTexture(channel: number, texture: InternalTexture): void;
  53109. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  53110. releaseEffects(): void;
  53111. /** @hidden */
  53112. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53113. /** @hidden */
  53114. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53115. /** @hidden */
  53116. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53117. /** @hidden */
  53118. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  53119. }
  53120. }
  53121. declare module BABYLON {
  53122. /**
  53123. * Gather the list of clipboard event types as constants.
  53124. */
  53125. export class ClipboardEventTypes {
  53126. /**
  53127. * The clipboard event is fired when a copy command is active (pressed).
  53128. */
  53129. static readonly COPY: number;
  53130. /**
  53131. * The clipboard event is fired when a cut command is active (pressed).
  53132. */
  53133. static readonly CUT: number;
  53134. /**
  53135. * The clipboard event is fired when a paste command is active (pressed).
  53136. */
  53137. static readonly PASTE: number;
  53138. }
  53139. /**
  53140. * This class is used to store clipboard related info for the onClipboardObservable event.
  53141. */
  53142. export class ClipboardInfo {
  53143. /**
  53144. * Defines the type of event (BABYLON.ClipboardEventTypes)
  53145. */
  53146. type: number;
  53147. /**
  53148. * Defines the related dom event
  53149. */
  53150. event: ClipboardEvent;
  53151. /**
  53152. *Creates an instance of ClipboardInfo.
  53153. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  53154. * @param event Defines the related dom event
  53155. */
  53156. constructor(
  53157. /**
  53158. * Defines the type of event (BABYLON.ClipboardEventTypes)
  53159. */
  53160. type: number,
  53161. /**
  53162. * Defines the related dom event
  53163. */
  53164. event: ClipboardEvent);
  53165. /**
  53166. * Get the clipboard event's type from the keycode.
  53167. * @param keyCode Defines the keyCode for the current keyboard event.
  53168. * @return {number}
  53169. */
  53170. static GetTypeFromCharacter(keyCode: number): number;
  53171. }
  53172. }
  53173. declare module BABYLON {
  53174. /**
  53175. * Google Daydream controller
  53176. */
  53177. export class DaydreamController extends WebVRController {
  53178. /**
  53179. * Base Url for the controller model.
  53180. */
  53181. static MODEL_BASE_URL: string;
  53182. /**
  53183. * File name for the controller model.
  53184. */
  53185. static MODEL_FILENAME: string;
  53186. /**
  53187. * Gamepad Id prefix used to identify Daydream Controller.
  53188. */
  53189. static readonly GAMEPAD_ID_PREFIX: string;
  53190. /**
  53191. * Creates a new DaydreamController from a gamepad
  53192. * @param vrGamepad the gamepad that the controller should be created from
  53193. */
  53194. constructor(vrGamepad: any);
  53195. /**
  53196. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53197. * @param scene scene in which to add meshes
  53198. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53199. */
  53200. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53201. /**
  53202. * Called once for each button that changed state since the last frame
  53203. * @param buttonIdx Which button index changed
  53204. * @param state New state of the button
  53205. * @param changes Which properties on the state changed since last frame
  53206. */
  53207. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53208. }
  53209. }
  53210. declare module BABYLON {
  53211. /**
  53212. * Gear VR Controller
  53213. */
  53214. export class GearVRController extends WebVRController {
  53215. /**
  53216. * Base Url for the controller model.
  53217. */
  53218. static MODEL_BASE_URL: string;
  53219. /**
  53220. * File name for the controller model.
  53221. */
  53222. static MODEL_FILENAME: string;
  53223. /**
  53224. * Gamepad Id prefix used to identify this controller.
  53225. */
  53226. static readonly GAMEPAD_ID_PREFIX: string;
  53227. private readonly _buttonIndexToObservableNameMap;
  53228. /**
  53229. * Creates a new GearVRController from a gamepad
  53230. * @param vrGamepad the gamepad that the controller should be created from
  53231. */
  53232. constructor(vrGamepad: any);
  53233. /**
  53234. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53235. * @param scene scene in which to add meshes
  53236. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53237. */
  53238. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53239. /**
  53240. * Called once for each button that changed state since the last frame
  53241. * @param buttonIdx Which button index changed
  53242. * @param state New state of the button
  53243. * @param changes Which properties on the state changed since last frame
  53244. */
  53245. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53246. }
  53247. }
  53248. declare module BABYLON {
  53249. /**
  53250. * Generic Controller
  53251. */
  53252. export class GenericController extends WebVRController {
  53253. /**
  53254. * Base Url for the controller model.
  53255. */
  53256. static readonly MODEL_BASE_URL: string;
  53257. /**
  53258. * File name for the controller model.
  53259. */
  53260. static readonly MODEL_FILENAME: string;
  53261. /**
  53262. * Creates a new GenericController from a gamepad
  53263. * @param vrGamepad the gamepad that the controller should be created from
  53264. */
  53265. constructor(vrGamepad: any);
  53266. /**
  53267. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53268. * @param scene scene in which to add meshes
  53269. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53270. */
  53271. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53272. /**
  53273. * Called once for each button that changed state since the last frame
  53274. * @param buttonIdx Which button index changed
  53275. * @param state New state of the button
  53276. * @param changes Which properties on the state changed since last frame
  53277. */
  53278. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53279. }
  53280. }
  53281. declare module BABYLON {
  53282. /**
  53283. * Oculus Touch Controller
  53284. */
  53285. export class OculusTouchController extends WebVRController {
  53286. /**
  53287. * Base Url for the controller model.
  53288. */
  53289. static MODEL_BASE_URL: string;
  53290. /**
  53291. * File name for the left controller model.
  53292. */
  53293. static MODEL_LEFT_FILENAME: string;
  53294. /**
  53295. * File name for the right controller model.
  53296. */
  53297. static MODEL_RIGHT_FILENAME: string;
  53298. /**
  53299. * Base Url for the Quest controller model.
  53300. */
  53301. static QUEST_MODEL_BASE_URL: string;
  53302. /**
  53303. * @hidden
  53304. * If the controllers are running on a device that needs the updated Quest controller models
  53305. */
  53306. static _IsQuest: boolean;
  53307. /**
  53308. * Fired when the secondary trigger on this controller is modified
  53309. */
  53310. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  53311. /**
  53312. * Fired when the thumb rest on this controller is modified
  53313. */
  53314. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  53315. /**
  53316. * Creates a new OculusTouchController from a gamepad
  53317. * @param vrGamepad the gamepad that the controller should be created from
  53318. */
  53319. constructor(vrGamepad: any);
  53320. /**
  53321. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53322. * @param scene scene in which to add meshes
  53323. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53324. */
  53325. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53326. /**
  53327. * Fired when the A button on this controller is modified
  53328. */
  53329. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53330. /**
  53331. * Fired when the B button on this controller is modified
  53332. */
  53333. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53334. /**
  53335. * Fired when the X button on this controller is modified
  53336. */
  53337. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53338. /**
  53339. * Fired when the Y button on this controller is modified
  53340. */
  53341. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53342. /**
  53343. * Called once for each button that changed state since the last frame
  53344. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  53345. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  53346. * 2) secondary trigger (same)
  53347. * 3) A (right) X (left), touch, pressed = value
  53348. * 4) B / Y
  53349. * 5) thumb rest
  53350. * @param buttonIdx Which button index changed
  53351. * @param state New state of the button
  53352. * @param changes Which properties on the state changed since last frame
  53353. */
  53354. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53355. }
  53356. }
  53357. declare module BABYLON {
  53358. /**
  53359. * Vive Controller
  53360. */
  53361. export class ViveController extends WebVRController {
  53362. /**
  53363. * Base Url for the controller model.
  53364. */
  53365. static MODEL_BASE_URL: string;
  53366. /**
  53367. * File name for the controller model.
  53368. */
  53369. static MODEL_FILENAME: string;
  53370. /**
  53371. * Creates a new ViveController from a gamepad
  53372. * @param vrGamepad the gamepad that the controller should be created from
  53373. */
  53374. constructor(vrGamepad: any);
  53375. /**
  53376. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53377. * @param scene scene in which to add meshes
  53378. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53379. */
  53380. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53381. /**
  53382. * Fired when the left button on this controller is modified
  53383. */
  53384. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53385. /**
  53386. * Fired when the right button on this controller is modified
  53387. */
  53388. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53389. /**
  53390. * Fired when the menu button on this controller is modified
  53391. */
  53392. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53393. /**
  53394. * Called once for each button that changed state since the last frame
  53395. * Vive mapping:
  53396. * 0: touchpad
  53397. * 1: trigger
  53398. * 2: left AND right buttons
  53399. * 3: menu button
  53400. * @param buttonIdx Which button index changed
  53401. * @param state New state of the button
  53402. * @param changes Which properties on the state changed since last frame
  53403. */
  53404. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53405. }
  53406. }
  53407. declare module BABYLON {
  53408. /**
  53409. * Defines the WindowsMotionController object that the state of the windows motion controller
  53410. */
  53411. export class WindowsMotionController extends WebVRController {
  53412. /**
  53413. * The base url used to load the left and right controller models
  53414. */
  53415. static MODEL_BASE_URL: string;
  53416. /**
  53417. * The name of the left controller model file
  53418. */
  53419. static MODEL_LEFT_FILENAME: string;
  53420. /**
  53421. * The name of the right controller model file
  53422. */
  53423. static MODEL_RIGHT_FILENAME: string;
  53424. /**
  53425. * The controller name prefix for this controller type
  53426. */
  53427. static readonly GAMEPAD_ID_PREFIX: string;
  53428. /**
  53429. * The controller id pattern for this controller type
  53430. */
  53431. private static readonly GAMEPAD_ID_PATTERN;
  53432. private _loadedMeshInfo;
  53433. protected readonly _mapping: {
  53434. buttons: string[];
  53435. buttonMeshNames: {
  53436. trigger: string;
  53437. menu: string;
  53438. grip: string;
  53439. thumbstick: string;
  53440. trackpad: string;
  53441. };
  53442. buttonObservableNames: {
  53443. trigger: string;
  53444. menu: string;
  53445. grip: string;
  53446. thumbstick: string;
  53447. trackpad: string;
  53448. };
  53449. axisMeshNames: string[];
  53450. pointingPoseMeshName: string;
  53451. };
  53452. /**
  53453. * Fired when the trackpad on this controller is clicked
  53454. */
  53455. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53456. /**
  53457. * Fired when the trackpad on this controller is modified
  53458. */
  53459. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53460. /**
  53461. * The current x and y values of this controller's trackpad
  53462. */
  53463. trackpad: StickValues;
  53464. /**
  53465. * Creates a new WindowsMotionController from a gamepad
  53466. * @param vrGamepad the gamepad that the controller should be created from
  53467. */
  53468. constructor(vrGamepad: any);
  53469. /**
  53470. * Fired when the trigger on this controller is modified
  53471. */
  53472. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53473. /**
  53474. * Fired when the menu button on this controller is modified
  53475. */
  53476. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53477. /**
  53478. * Fired when the grip button on this controller is modified
  53479. */
  53480. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53481. /**
  53482. * Fired when the thumbstick button on this controller is modified
  53483. */
  53484. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53485. /**
  53486. * Fired when the touchpad button on this controller is modified
  53487. */
  53488. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53489. /**
  53490. * Fired when the touchpad values on this controller are modified
  53491. */
  53492. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  53493. protected _updateTrackpad(): void;
  53494. /**
  53495. * Called once per frame by the engine.
  53496. */
  53497. update(): void;
  53498. /**
  53499. * Called once for each button that changed state since the last frame
  53500. * @param buttonIdx Which button index changed
  53501. * @param state New state of the button
  53502. * @param changes Which properties on the state changed since last frame
  53503. */
  53504. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53505. /**
  53506. * Moves the buttons on the controller mesh based on their current state
  53507. * @param buttonName the name of the button to move
  53508. * @param buttonValue the value of the button which determines the buttons new position
  53509. */
  53510. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  53511. /**
  53512. * Moves the axis on the controller mesh based on its current state
  53513. * @param axis the index of the axis
  53514. * @param axisValue the value of the axis which determines the meshes new position
  53515. * @hidden
  53516. */
  53517. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  53518. /**
  53519. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53520. * @param scene scene in which to add meshes
  53521. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53522. */
  53523. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  53524. /**
  53525. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  53526. * can be transformed by button presses and axes values, based on this._mapping.
  53527. *
  53528. * @param scene scene in which the meshes exist
  53529. * @param meshes list of meshes that make up the controller model to process
  53530. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  53531. */
  53532. private processModel;
  53533. private createMeshInfo;
  53534. /**
  53535. * Gets the ray of the controller in the direction the controller is pointing
  53536. * @param length the length the resulting ray should be
  53537. * @returns a ray in the direction the controller is pointing
  53538. */
  53539. getForwardRay(length?: number): Ray;
  53540. /**
  53541. * Disposes of the controller
  53542. */
  53543. dispose(): void;
  53544. }
  53545. /**
  53546. * This class represents a new windows motion controller in XR.
  53547. */
  53548. export class XRWindowsMotionController extends WindowsMotionController {
  53549. /**
  53550. * Changing the original WIndowsMotionController mapping to fir the new mapping
  53551. */
  53552. protected readonly _mapping: {
  53553. buttons: string[];
  53554. buttonMeshNames: {
  53555. trigger: string;
  53556. menu: string;
  53557. grip: string;
  53558. thumbstick: string;
  53559. trackpad: string;
  53560. };
  53561. buttonObservableNames: {
  53562. trigger: string;
  53563. menu: string;
  53564. grip: string;
  53565. thumbstick: string;
  53566. trackpad: string;
  53567. };
  53568. axisMeshNames: string[];
  53569. pointingPoseMeshName: string;
  53570. };
  53571. /**
  53572. * Construct a new XR-Based windows motion controller
  53573. *
  53574. * @param gamepadInfo the gamepad object from the browser
  53575. */
  53576. constructor(gamepadInfo: any);
  53577. /**
  53578. * holds the thumbstick values (X,Y)
  53579. */
  53580. thumbstickValues: StickValues;
  53581. /**
  53582. * Fired when the thumbstick on this controller is clicked
  53583. */
  53584. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  53585. /**
  53586. * Fired when the thumbstick on this controller is modified
  53587. */
  53588. onThumbstickValuesChangedObservable: Observable<StickValues>;
  53589. /**
  53590. * Fired when the touchpad button on this controller is modified
  53591. */
  53592. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53593. /**
  53594. * Fired when the touchpad values on this controller are modified
  53595. */
  53596. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53597. /**
  53598. * Fired when the thumbstick button on this controller is modified
  53599. * here to prevent breaking changes
  53600. */
  53601. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53602. /**
  53603. * updating the thumbstick(!) and not the trackpad.
  53604. * This is named this way due to the difference between WebVR and XR and to avoid
  53605. * changing the parent class.
  53606. */
  53607. protected _updateTrackpad(): void;
  53608. /**
  53609. * Disposes the class with joy
  53610. */
  53611. dispose(): void;
  53612. }
  53613. }
  53614. declare module BABYLON {
  53615. /**
  53616. * Class containing static functions to help procedurally build meshes
  53617. */
  53618. export class PolyhedronBuilder {
  53619. /**
  53620. * Creates a polyhedron mesh
  53621. * * 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
  53622. * * The parameter `size` (positive float, default 1) sets the polygon size
  53623. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  53624. * * 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`
  53625. * * 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
  53626. * * 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)`)
  53627. * * 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
  53628. * * 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
  53629. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53630. * * 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
  53631. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53632. * @param name defines the name of the mesh
  53633. * @param options defines the options used to create the mesh
  53634. * @param scene defines the hosting scene
  53635. * @returns the polyhedron mesh
  53636. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  53637. */
  53638. static CreatePolyhedron(name: string, options: {
  53639. type?: number;
  53640. size?: number;
  53641. sizeX?: number;
  53642. sizeY?: number;
  53643. sizeZ?: number;
  53644. custom?: any;
  53645. faceUV?: Vector4[];
  53646. faceColors?: Color4[];
  53647. flat?: boolean;
  53648. updatable?: boolean;
  53649. sideOrientation?: number;
  53650. frontUVs?: Vector4;
  53651. backUVs?: Vector4;
  53652. }, scene?: Nullable<Scene>): Mesh;
  53653. }
  53654. }
  53655. declare module BABYLON {
  53656. /**
  53657. * Gizmo that enables scaling a mesh along 3 axis
  53658. */
  53659. export class ScaleGizmo extends Gizmo {
  53660. /**
  53661. * Internal gizmo used for interactions on the x axis
  53662. */
  53663. xGizmo: AxisScaleGizmo;
  53664. /**
  53665. * Internal gizmo used for interactions on the y axis
  53666. */
  53667. yGizmo: AxisScaleGizmo;
  53668. /**
  53669. * Internal gizmo used for interactions on the z axis
  53670. */
  53671. zGizmo: AxisScaleGizmo;
  53672. /**
  53673. * Internal gizmo used to scale all axis equally
  53674. */
  53675. uniformScaleGizmo: AxisScaleGizmo;
  53676. private _meshAttached;
  53677. private _nodeAttached;
  53678. private _snapDistance;
  53679. private _uniformScalingMesh;
  53680. private _octahedron;
  53681. private _sensitivity;
  53682. /** Fires an event when any of it's sub gizmos are dragged */
  53683. onDragStartObservable: Observable<unknown>;
  53684. /** Fires an event when any of it's sub gizmos are released from dragging */
  53685. onDragEndObservable: Observable<unknown>;
  53686. get attachedMesh(): Nullable<AbstractMesh>;
  53687. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53688. get attachedNode(): Nullable<Node>;
  53689. set attachedNode(node: Nullable<Node>);
  53690. /**
  53691. * True when the mouse pointer is hovering a gizmo mesh
  53692. */
  53693. get isHovered(): boolean;
  53694. /**
  53695. * Creates a ScaleGizmo
  53696. * @param gizmoLayer The utility layer the gizmo will be added to
  53697. * @param thickness display gizmo axis thickness
  53698. */
  53699. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  53700. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53701. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53702. /**
  53703. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53704. */
  53705. set snapDistance(value: number);
  53706. get snapDistance(): number;
  53707. /**
  53708. * Ratio for the scale of the gizmo (Default: 1)
  53709. */
  53710. set scaleRatio(value: number);
  53711. get scaleRatio(): number;
  53712. /**
  53713. * Sensitivity factor for dragging (Default: 1)
  53714. */
  53715. set sensitivity(value: number);
  53716. get sensitivity(): number;
  53717. /**
  53718. * Disposes of the gizmo
  53719. */
  53720. dispose(): void;
  53721. }
  53722. }
  53723. declare module BABYLON {
  53724. /**
  53725. * Single axis scale gizmo
  53726. */
  53727. export class AxisScaleGizmo extends Gizmo {
  53728. /**
  53729. * Drag behavior responsible for the gizmos dragging interactions
  53730. */
  53731. dragBehavior: PointerDragBehavior;
  53732. private _pointerObserver;
  53733. /**
  53734. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53735. */
  53736. snapDistance: number;
  53737. /**
  53738. * Event that fires each time the gizmo snaps to a new location.
  53739. * * snapDistance is the the change in distance
  53740. */
  53741. onSnapObservable: Observable<{
  53742. snapDistance: number;
  53743. }>;
  53744. /**
  53745. * If the scaling operation should be done on all axis (default: false)
  53746. */
  53747. uniformScaling: boolean;
  53748. /**
  53749. * Custom sensitivity value for the drag strength
  53750. */
  53751. sensitivity: number;
  53752. private _isEnabled;
  53753. private _parent;
  53754. private _arrow;
  53755. private _coloredMaterial;
  53756. private _hoverMaterial;
  53757. /**
  53758. * Creates an AxisScaleGizmo
  53759. * @param gizmoLayer The utility layer the gizmo will be added to
  53760. * @param dragAxis The axis which the gizmo will be able to scale on
  53761. * @param color The color of the gizmo
  53762. * @param thickness display gizmo axis thickness
  53763. */
  53764. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  53765. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53766. /**
  53767. * If the gizmo is enabled
  53768. */
  53769. set isEnabled(value: boolean);
  53770. get isEnabled(): boolean;
  53771. /**
  53772. * Disposes of the gizmo
  53773. */
  53774. dispose(): void;
  53775. /**
  53776. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  53777. * @param mesh The mesh to replace the default mesh of the gizmo
  53778. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  53779. */
  53780. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  53781. }
  53782. }
  53783. declare module BABYLON {
  53784. /**
  53785. * Bounding box gizmo
  53786. */
  53787. export class BoundingBoxGizmo extends Gizmo {
  53788. private _lineBoundingBox;
  53789. private _rotateSpheresParent;
  53790. private _scaleBoxesParent;
  53791. private _boundingDimensions;
  53792. private _renderObserver;
  53793. private _pointerObserver;
  53794. private _scaleDragSpeed;
  53795. private _tmpQuaternion;
  53796. private _tmpVector;
  53797. private _tmpRotationMatrix;
  53798. /**
  53799. * 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)
  53800. */
  53801. ignoreChildren: boolean;
  53802. /**
  53803. * 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)
  53804. */
  53805. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  53806. /**
  53807. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  53808. */
  53809. rotationSphereSize: number;
  53810. /**
  53811. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  53812. */
  53813. scaleBoxSize: number;
  53814. /**
  53815. * 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)
  53816. */
  53817. fixedDragMeshScreenSize: boolean;
  53818. /**
  53819. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  53820. */
  53821. fixedDragMeshScreenSizeDistanceFactor: number;
  53822. /**
  53823. * Fired when a rotation sphere or scale box is dragged
  53824. */
  53825. onDragStartObservable: Observable<{}>;
  53826. /**
  53827. * Fired when a scale box is dragged
  53828. */
  53829. onScaleBoxDragObservable: Observable<{}>;
  53830. /**
  53831. * Fired when a scale box drag is ended
  53832. */
  53833. onScaleBoxDragEndObservable: Observable<{}>;
  53834. /**
  53835. * Fired when a rotation sphere is dragged
  53836. */
  53837. onRotationSphereDragObservable: Observable<{}>;
  53838. /**
  53839. * Fired when a rotation sphere drag is ended
  53840. */
  53841. onRotationSphereDragEndObservable: Observable<{}>;
  53842. /**
  53843. * 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)
  53844. */
  53845. scalePivot: Nullable<Vector3>;
  53846. /**
  53847. * Mesh used as a pivot to rotate the attached node
  53848. */
  53849. private _anchorMesh;
  53850. private _existingMeshScale;
  53851. private _dragMesh;
  53852. private pointerDragBehavior;
  53853. private coloredMaterial;
  53854. private hoverColoredMaterial;
  53855. /**
  53856. * Sets the color of the bounding box gizmo
  53857. * @param color the color to set
  53858. */
  53859. setColor(color: Color3): void;
  53860. /**
  53861. * Creates an BoundingBoxGizmo
  53862. * @param gizmoLayer The utility layer the gizmo will be added to
  53863. * @param color The color of the gizmo
  53864. */
  53865. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  53866. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  53867. private _selectNode;
  53868. /**
  53869. * Updates the bounding box information for the Gizmo
  53870. */
  53871. updateBoundingBox(): void;
  53872. private _updateRotationSpheres;
  53873. private _updateScaleBoxes;
  53874. /**
  53875. * Enables rotation on the specified axis and disables rotation on the others
  53876. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  53877. */
  53878. setEnabledRotationAxis(axis: string): void;
  53879. /**
  53880. * Enables/disables scaling
  53881. * @param enable if scaling should be enabled
  53882. * @param homogeneousScaling defines if scaling should only be homogeneous
  53883. */
  53884. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  53885. private _updateDummy;
  53886. /**
  53887. * Enables a pointer drag behavior on the bounding box of the gizmo
  53888. */
  53889. enableDragBehavior(): void;
  53890. /**
  53891. * Disposes of the gizmo
  53892. */
  53893. dispose(): void;
  53894. /**
  53895. * 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)
  53896. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  53897. * @returns the bounding box mesh with the passed in mesh as a child
  53898. */
  53899. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  53900. /**
  53901. * CustomMeshes are not supported by this gizmo
  53902. * @param mesh The mesh to replace the default mesh of the gizmo
  53903. */
  53904. setCustomMesh(mesh: Mesh): void;
  53905. }
  53906. }
  53907. declare module BABYLON {
  53908. /**
  53909. * Single plane rotation gizmo
  53910. */
  53911. export class PlaneRotationGizmo extends Gizmo {
  53912. /**
  53913. * Drag behavior responsible for the gizmos dragging interactions
  53914. */
  53915. dragBehavior: PointerDragBehavior;
  53916. private _pointerObserver;
  53917. /**
  53918. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  53919. */
  53920. snapDistance: number;
  53921. /**
  53922. * Event that fires each time the gizmo snaps to a new location.
  53923. * * snapDistance is the the change in distance
  53924. */
  53925. onSnapObservable: Observable<{
  53926. snapDistance: number;
  53927. }>;
  53928. private _isEnabled;
  53929. private _parent;
  53930. /**
  53931. * Creates a PlaneRotationGizmo
  53932. * @param gizmoLayer The utility layer the gizmo will be added to
  53933. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  53934. * @param color The color of the gizmo
  53935. * @param tessellation Amount of tessellation to be used when creating rotation circles
  53936. * @param useEulerRotation Use and update Euler angle instead of quaternion
  53937. * @param thickness display gizmo axis thickness
  53938. */
  53939. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  53940. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53941. /**
  53942. * If the gizmo is enabled
  53943. */
  53944. set isEnabled(value: boolean);
  53945. get isEnabled(): boolean;
  53946. /**
  53947. * Disposes of the gizmo
  53948. */
  53949. dispose(): void;
  53950. }
  53951. }
  53952. declare module BABYLON {
  53953. /**
  53954. * Gizmo that enables rotating a mesh along 3 axis
  53955. */
  53956. export class RotationGizmo extends Gizmo {
  53957. /**
  53958. * Internal gizmo used for interactions on the x axis
  53959. */
  53960. xGizmo: PlaneRotationGizmo;
  53961. /**
  53962. * Internal gizmo used for interactions on the y axis
  53963. */
  53964. yGizmo: PlaneRotationGizmo;
  53965. /**
  53966. * Internal gizmo used for interactions on the z axis
  53967. */
  53968. zGizmo: PlaneRotationGizmo;
  53969. /** Fires an event when any of it's sub gizmos are dragged */
  53970. onDragStartObservable: Observable<unknown>;
  53971. /** Fires an event when any of it's sub gizmos are released from dragging */
  53972. onDragEndObservable: Observable<unknown>;
  53973. private _meshAttached;
  53974. private _nodeAttached;
  53975. get attachedMesh(): Nullable<AbstractMesh>;
  53976. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53977. get attachedNode(): Nullable<Node>;
  53978. set attachedNode(node: Nullable<Node>);
  53979. /**
  53980. * True when the mouse pointer is hovering a gizmo mesh
  53981. */
  53982. get isHovered(): boolean;
  53983. /**
  53984. * Creates a RotationGizmo
  53985. * @param gizmoLayer The utility layer the gizmo will be added to
  53986. * @param tessellation Amount of tessellation to be used when creating rotation circles
  53987. * @param useEulerRotation Use and update Euler angle instead of quaternion
  53988. * @param thickness display gizmo axis thickness
  53989. */
  53990. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  53991. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53992. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53993. /**
  53994. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53995. */
  53996. set snapDistance(value: number);
  53997. get snapDistance(): number;
  53998. /**
  53999. * Ratio for the scale of the gizmo (Default: 1)
  54000. */
  54001. set scaleRatio(value: number);
  54002. get scaleRatio(): number;
  54003. /**
  54004. * Disposes of the gizmo
  54005. */
  54006. dispose(): void;
  54007. /**
  54008. * CustomMeshes are not supported by this gizmo
  54009. * @param mesh The mesh to replace the default mesh of the gizmo
  54010. */
  54011. setCustomMesh(mesh: Mesh): void;
  54012. }
  54013. }
  54014. declare module BABYLON {
  54015. /**
  54016. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  54017. */
  54018. export class GizmoManager implements IDisposable {
  54019. private scene;
  54020. /**
  54021. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  54022. */
  54023. gizmos: {
  54024. positionGizmo: Nullable<PositionGizmo>;
  54025. rotationGizmo: Nullable<RotationGizmo>;
  54026. scaleGizmo: Nullable<ScaleGizmo>;
  54027. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  54028. };
  54029. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  54030. clearGizmoOnEmptyPointerEvent: boolean;
  54031. /** Fires an event when the manager is attached to a mesh */
  54032. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  54033. /** Fires an event when the manager is attached to a node */
  54034. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  54035. private _gizmosEnabled;
  54036. private _pointerObserver;
  54037. private _attachedMesh;
  54038. private _attachedNode;
  54039. private _boundingBoxColor;
  54040. private _defaultUtilityLayer;
  54041. private _defaultKeepDepthUtilityLayer;
  54042. private _thickness;
  54043. /**
  54044. * When bounding box gizmo is enabled, this can be used to track drag/end events
  54045. */
  54046. boundingBoxDragBehavior: SixDofDragBehavior;
  54047. /**
  54048. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  54049. */
  54050. attachableMeshes: Nullable<Array<AbstractMesh>>;
  54051. /**
  54052. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  54053. */
  54054. attachableNodes: Nullable<Array<Node>>;
  54055. /**
  54056. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  54057. */
  54058. usePointerToAttachGizmos: boolean;
  54059. /**
  54060. * Utility layer that the bounding box gizmo belongs to
  54061. */
  54062. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  54063. /**
  54064. * Utility layer that all gizmos besides bounding box belong to
  54065. */
  54066. get utilityLayer(): UtilityLayerRenderer;
  54067. /**
  54068. * True when the mouse pointer is hovering a gizmo mesh
  54069. */
  54070. get isHovered(): boolean;
  54071. /**
  54072. * Instatiates a gizmo manager
  54073. * @param scene the scene to overlay the gizmos on top of
  54074. * @param thickness display gizmo axis thickness
  54075. */
  54076. constructor(scene: Scene, thickness?: number);
  54077. /**
  54078. * Attaches a set of gizmos to the specified mesh
  54079. * @param mesh The mesh the gizmo's should be attached to
  54080. */
  54081. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54082. /**
  54083. * Attaches a set of gizmos to the specified node
  54084. * @param node The node the gizmo's should be attached to
  54085. */
  54086. attachToNode(node: Nullable<Node>): void;
  54087. /**
  54088. * If the position gizmo is enabled
  54089. */
  54090. set positionGizmoEnabled(value: boolean);
  54091. get positionGizmoEnabled(): boolean;
  54092. /**
  54093. * If the rotation gizmo is enabled
  54094. */
  54095. set rotationGizmoEnabled(value: boolean);
  54096. get rotationGizmoEnabled(): boolean;
  54097. /**
  54098. * If the scale gizmo is enabled
  54099. */
  54100. set scaleGizmoEnabled(value: boolean);
  54101. get scaleGizmoEnabled(): boolean;
  54102. /**
  54103. * If the boundingBox gizmo is enabled
  54104. */
  54105. set boundingBoxGizmoEnabled(value: boolean);
  54106. get boundingBoxGizmoEnabled(): boolean;
  54107. /**
  54108. * Disposes of the gizmo manager
  54109. */
  54110. dispose(): void;
  54111. }
  54112. }
  54113. declare module BABYLON {
  54114. /**
  54115. * A directional light is defined by a direction (what a surprise!).
  54116. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  54117. * 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.
  54118. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54119. */
  54120. export class DirectionalLight extends ShadowLight {
  54121. private _shadowFrustumSize;
  54122. /**
  54123. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  54124. */
  54125. get shadowFrustumSize(): number;
  54126. /**
  54127. * Specifies a fix frustum size for the shadow generation.
  54128. */
  54129. set shadowFrustumSize(value: number);
  54130. private _shadowOrthoScale;
  54131. /**
  54132. * Gets the shadow projection scale against the optimal computed one.
  54133. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  54134. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  54135. */
  54136. get shadowOrthoScale(): number;
  54137. /**
  54138. * Sets the shadow projection scale against the optimal computed one.
  54139. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  54140. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  54141. */
  54142. set shadowOrthoScale(value: number);
  54143. /**
  54144. * Automatically compute the projection matrix to best fit (including all the casters)
  54145. * on each frame.
  54146. */
  54147. autoUpdateExtends: boolean;
  54148. /**
  54149. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  54150. * on each frame. autoUpdateExtends must be set to true for this to work
  54151. */
  54152. autoCalcShadowZBounds: boolean;
  54153. private _orthoLeft;
  54154. private _orthoRight;
  54155. private _orthoTop;
  54156. private _orthoBottom;
  54157. /**
  54158. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  54159. * The directional light is emitted from everywhere in the given direction.
  54160. * It can cast shadows.
  54161. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54162. * @param name The friendly name of the light
  54163. * @param direction The direction of the light
  54164. * @param scene The scene the light belongs to
  54165. */
  54166. constructor(name: string, direction: Vector3, scene: Scene);
  54167. /**
  54168. * Returns the string "DirectionalLight".
  54169. * @return The class name
  54170. */
  54171. getClassName(): string;
  54172. /**
  54173. * Returns the integer 1.
  54174. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54175. */
  54176. getTypeID(): number;
  54177. /**
  54178. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  54179. * Returns the DirectionalLight Shadow projection matrix.
  54180. */
  54181. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54182. /**
  54183. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  54184. * Returns the DirectionalLight Shadow projection matrix.
  54185. */
  54186. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  54187. /**
  54188. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  54189. * Returns the DirectionalLight Shadow projection matrix.
  54190. */
  54191. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54192. protected _buildUniformLayout(): void;
  54193. /**
  54194. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  54195. * @param effect The effect to update
  54196. * @param lightIndex The index of the light in the effect to update
  54197. * @returns The directional light
  54198. */
  54199. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  54200. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  54201. /**
  54202. * Gets the minZ used for shadow according to both the scene and the light.
  54203. *
  54204. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  54205. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  54206. * @param activeCamera The camera we are returning the min for
  54207. * @returns the depth min z
  54208. */
  54209. getDepthMinZ(activeCamera: Camera): number;
  54210. /**
  54211. * Gets the maxZ used for shadow according to both the scene and the light.
  54212. *
  54213. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  54214. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  54215. * @param activeCamera The camera we are returning the max for
  54216. * @returns the depth max z
  54217. */
  54218. getDepthMaxZ(activeCamera: Camera): number;
  54219. /**
  54220. * Prepares the list of defines specific to the light type.
  54221. * @param defines the list of defines
  54222. * @param lightIndex defines the index of the light for the effect
  54223. */
  54224. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54225. }
  54226. }
  54227. declare module BABYLON {
  54228. /**
  54229. * Class containing static functions to help procedurally build meshes
  54230. */
  54231. export class HemisphereBuilder {
  54232. /**
  54233. * Creates a hemisphere mesh
  54234. * @param name defines the name of the mesh
  54235. * @param options defines the options used to create the mesh
  54236. * @param scene defines the hosting scene
  54237. * @returns the hemisphere mesh
  54238. */
  54239. static CreateHemisphere(name: string, options: {
  54240. segments?: number;
  54241. diameter?: number;
  54242. sideOrientation?: number;
  54243. }, scene: any): Mesh;
  54244. }
  54245. }
  54246. declare module BABYLON {
  54247. /**
  54248. * A spot light is defined by a position, a direction, an angle, and an exponent.
  54249. * These values define a cone of light starting from the position, emitting toward the direction.
  54250. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  54251. * and the exponent defines the speed of the decay of the light with distance (reach).
  54252. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54253. */
  54254. export class SpotLight extends ShadowLight {
  54255. private _angle;
  54256. private _innerAngle;
  54257. private _cosHalfAngle;
  54258. private _lightAngleScale;
  54259. private _lightAngleOffset;
  54260. /**
  54261. * Gets the cone angle of the spot light in Radians.
  54262. */
  54263. get angle(): number;
  54264. /**
  54265. * Sets the cone angle of the spot light in Radians.
  54266. */
  54267. set angle(value: number);
  54268. /**
  54269. * Only used in gltf falloff mode, this defines the angle where
  54270. * the directional falloff will start before cutting at angle which could be seen
  54271. * as outer angle.
  54272. */
  54273. get innerAngle(): number;
  54274. /**
  54275. * Only used in gltf falloff mode, this defines the angle where
  54276. * the directional falloff will start before cutting at angle which could be seen
  54277. * as outer angle.
  54278. */
  54279. set innerAngle(value: number);
  54280. private _shadowAngleScale;
  54281. /**
  54282. * Allows scaling the angle of the light for shadow generation only.
  54283. */
  54284. get shadowAngleScale(): number;
  54285. /**
  54286. * Allows scaling the angle of the light for shadow generation only.
  54287. */
  54288. set shadowAngleScale(value: number);
  54289. /**
  54290. * The light decay speed with the distance from the emission spot.
  54291. */
  54292. exponent: number;
  54293. private _projectionTextureMatrix;
  54294. /**
  54295. * Allows reading the projecton texture
  54296. */
  54297. get projectionTextureMatrix(): Matrix;
  54298. protected _projectionTextureLightNear: number;
  54299. /**
  54300. * Gets the near clip of the Spotlight for texture projection.
  54301. */
  54302. get projectionTextureLightNear(): number;
  54303. /**
  54304. * Sets the near clip of the Spotlight for texture projection.
  54305. */
  54306. set projectionTextureLightNear(value: number);
  54307. protected _projectionTextureLightFar: number;
  54308. /**
  54309. * Gets the far clip of the Spotlight for texture projection.
  54310. */
  54311. get projectionTextureLightFar(): number;
  54312. /**
  54313. * Sets the far clip of the Spotlight for texture projection.
  54314. */
  54315. set projectionTextureLightFar(value: number);
  54316. protected _projectionTextureUpDirection: Vector3;
  54317. /**
  54318. * Gets the Up vector of the Spotlight for texture projection.
  54319. */
  54320. get projectionTextureUpDirection(): Vector3;
  54321. /**
  54322. * Sets the Up vector of the Spotlight for texture projection.
  54323. */
  54324. set projectionTextureUpDirection(value: Vector3);
  54325. private _projectionTexture;
  54326. /**
  54327. * Gets the projection texture of the light.
  54328. */
  54329. get projectionTexture(): Nullable<BaseTexture>;
  54330. /**
  54331. * Sets the projection texture of the light.
  54332. */
  54333. set projectionTexture(value: Nullable<BaseTexture>);
  54334. private _projectionTextureViewLightDirty;
  54335. private _projectionTextureProjectionLightDirty;
  54336. private _projectionTextureDirty;
  54337. private _projectionTextureViewTargetVector;
  54338. private _projectionTextureViewLightMatrix;
  54339. private _projectionTextureProjectionLightMatrix;
  54340. private _projectionTextureScalingMatrix;
  54341. /**
  54342. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  54343. * It can cast shadows.
  54344. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54345. * @param name The light friendly name
  54346. * @param position The position of the spot light in the scene
  54347. * @param direction The direction of the light in the scene
  54348. * @param angle The cone angle of the light in Radians
  54349. * @param exponent The light decay speed with the distance from the emission spot
  54350. * @param scene The scene the lights belongs to
  54351. */
  54352. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  54353. /**
  54354. * Returns the string "SpotLight".
  54355. * @returns the class name
  54356. */
  54357. getClassName(): string;
  54358. /**
  54359. * Returns the integer 2.
  54360. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54361. */
  54362. getTypeID(): number;
  54363. /**
  54364. * Overrides the direction setter to recompute the projection texture view light Matrix.
  54365. */
  54366. protected _setDirection(value: Vector3): void;
  54367. /**
  54368. * Overrides the position setter to recompute the projection texture view light Matrix.
  54369. */
  54370. protected _setPosition(value: Vector3): void;
  54371. /**
  54372. * 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.
  54373. * Returns the SpotLight.
  54374. */
  54375. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54376. protected _computeProjectionTextureViewLightMatrix(): void;
  54377. protected _computeProjectionTextureProjectionLightMatrix(): void;
  54378. /**
  54379. * Main function for light texture projection matrix computing.
  54380. */
  54381. protected _computeProjectionTextureMatrix(): void;
  54382. protected _buildUniformLayout(): void;
  54383. private _computeAngleValues;
  54384. /**
  54385. * Sets the passed Effect "effect" with the Light textures.
  54386. * @param effect The effect to update
  54387. * @param lightIndex The index of the light in the effect to update
  54388. * @returns The light
  54389. */
  54390. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  54391. /**
  54392. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  54393. * @param effect The effect to update
  54394. * @param lightIndex The index of the light in the effect to update
  54395. * @returns The spot light
  54396. */
  54397. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  54398. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54399. /**
  54400. * Disposes the light and the associated resources.
  54401. */
  54402. dispose(): void;
  54403. /**
  54404. * Prepares the list of defines specific to the light type.
  54405. * @param defines the list of defines
  54406. * @param lightIndex defines the index of the light for the effect
  54407. */
  54408. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54409. }
  54410. }
  54411. declare module BABYLON {
  54412. /**
  54413. * Gizmo that enables viewing a light
  54414. */
  54415. export class LightGizmo extends Gizmo {
  54416. private _lightMesh;
  54417. private _material;
  54418. private _cachedPosition;
  54419. private _cachedForward;
  54420. private _attachedMeshParent;
  54421. private _pointerObserver;
  54422. /**
  54423. * Event that fires each time the gizmo is clicked
  54424. */
  54425. onClickedObservable: Observable<Light>;
  54426. /**
  54427. * Creates a LightGizmo
  54428. * @param gizmoLayer The utility layer the gizmo will be added to
  54429. */
  54430. constructor(gizmoLayer?: UtilityLayerRenderer);
  54431. private _light;
  54432. /**
  54433. * The light that the gizmo is attached to
  54434. */
  54435. set light(light: Nullable<Light>);
  54436. get light(): Nullable<Light>;
  54437. /**
  54438. * Gets the material used to render the light gizmo
  54439. */
  54440. get material(): StandardMaterial;
  54441. /**
  54442. * @hidden
  54443. * Updates the gizmo to match the attached mesh's position/rotation
  54444. */
  54445. protected _update(): void;
  54446. private static _Scale;
  54447. /**
  54448. * Creates the lines for a light mesh
  54449. */
  54450. private static _CreateLightLines;
  54451. /**
  54452. * Disposes of the light gizmo
  54453. */
  54454. dispose(): void;
  54455. private static _CreateHemisphericLightMesh;
  54456. private static _CreatePointLightMesh;
  54457. private static _CreateSpotLightMesh;
  54458. private static _CreateDirectionalLightMesh;
  54459. }
  54460. }
  54461. declare module BABYLON {
  54462. /**
  54463. * Gizmo that enables viewing a camera
  54464. */
  54465. export class CameraGizmo extends Gizmo {
  54466. private _cameraMesh;
  54467. private _cameraLinesMesh;
  54468. private _material;
  54469. private _pointerObserver;
  54470. /**
  54471. * Event that fires each time the gizmo is clicked
  54472. */
  54473. onClickedObservable: Observable<Camera>;
  54474. /**
  54475. * Creates a CameraGizmo
  54476. * @param gizmoLayer The utility layer the gizmo will be added to
  54477. */
  54478. constructor(gizmoLayer?: UtilityLayerRenderer);
  54479. private _camera;
  54480. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  54481. get displayFrustum(): boolean;
  54482. set displayFrustum(value: boolean);
  54483. /**
  54484. * The camera that the gizmo is attached to
  54485. */
  54486. set camera(camera: Nullable<Camera>);
  54487. get camera(): Nullable<Camera>;
  54488. /**
  54489. * Gets the material used to render the camera gizmo
  54490. */
  54491. get material(): StandardMaterial;
  54492. /**
  54493. * @hidden
  54494. * Updates the gizmo to match the attached mesh's position/rotation
  54495. */
  54496. protected _update(): void;
  54497. private static _Scale;
  54498. private _invProjection;
  54499. /**
  54500. * Disposes of the camera gizmo
  54501. */
  54502. dispose(): void;
  54503. private static _CreateCameraMesh;
  54504. private static _CreateCameraFrustum;
  54505. }
  54506. }
  54507. declare module BABYLON {
  54508. /** @hidden */
  54509. export var backgroundFragmentDeclaration: {
  54510. name: string;
  54511. shader: string;
  54512. };
  54513. }
  54514. declare module BABYLON {
  54515. /** @hidden */
  54516. export var backgroundUboDeclaration: {
  54517. name: string;
  54518. shader: string;
  54519. };
  54520. }
  54521. declare module BABYLON {
  54522. /** @hidden */
  54523. export var backgroundPixelShader: {
  54524. name: string;
  54525. shader: string;
  54526. };
  54527. }
  54528. declare module BABYLON {
  54529. /** @hidden */
  54530. export var backgroundVertexDeclaration: {
  54531. name: string;
  54532. shader: string;
  54533. };
  54534. }
  54535. declare module BABYLON {
  54536. /** @hidden */
  54537. export var backgroundVertexShader: {
  54538. name: string;
  54539. shader: string;
  54540. };
  54541. }
  54542. declare module BABYLON {
  54543. /**
  54544. * Background material used to create an efficient environement around your scene.
  54545. */
  54546. export class BackgroundMaterial extends PushMaterial {
  54547. /**
  54548. * Standard reflectance value at parallel view angle.
  54549. */
  54550. static StandardReflectance0: number;
  54551. /**
  54552. * Standard reflectance value at grazing angle.
  54553. */
  54554. static StandardReflectance90: number;
  54555. protected _primaryColor: Color3;
  54556. /**
  54557. * Key light Color (multiply against the environement texture)
  54558. */
  54559. primaryColor: Color3;
  54560. protected __perceptualColor: Nullable<Color3>;
  54561. /**
  54562. * Experimental Internal Use Only.
  54563. *
  54564. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  54565. * This acts as a helper to set the primary color to a more "human friendly" value.
  54566. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  54567. * output color as close as possible from the chosen value.
  54568. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  54569. * part of lighting setup.)
  54570. */
  54571. get _perceptualColor(): Nullable<Color3>;
  54572. set _perceptualColor(value: Nullable<Color3>);
  54573. protected _primaryColorShadowLevel: float;
  54574. /**
  54575. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  54576. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  54577. */
  54578. get primaryColorShadowLevel(): float;
  54579. set primaryColorShadowLevel(value: float);
  54580. protected _primaryColorHighlightLevel: float;
  54581. /**
  54582. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  54583. * The primary color is used at the level chosen to define what the white area would look.
  54584. */
  54585. get primaryColorHighlightLevel(): float;
  54586. set primaryColorHighlightLevel(value: float);
  54587. protected _reflectionTexture: Nullable<BaseTexture>;
  54588. /**
  54589. * Reflection Texture used in the material.
  54590. * Should be author in a specific way for the best result (refer to the documentation).
  54591. */
  54592. reflectionTexture: Nullable<BaseTexture>;
  54593. protected _reflectionBlur: float;
  54594. /**
  54595. * Reflection Texture level of blur.
  54596. *
  54597. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  54598. * texture twice.
  54599. */
  54600. reflectionBlur: float;
  54601. protected _diffuseTexture: Nullable<BaseTexture>;
  54602. /**
  54603. * Diffuse Texture used in the material.
  54604. * Should be author in a specific way for the best result (refer to the documentation).
  54605. */
  54606. diffuseTexture: Nullable<BaseTexture>;
  54607. protected _shadowLights: Nullable<IShadowLight[]>;
  54608. /**
  54609. * Specify the list of lights casting shadow on the material.
  54610. * All scene shadow lights will be included if null.
  54611. */
  54612. shadowLights: Nullable<IShadowLight[]>;
  54613. protected _shadowLevel: float;
  54614. /**
  54615. * Helps adjusting the shadow to a softer level if required.
  54616. * 0 means black shadows and 1 means no shadows.
  54617. */
  54618. shadowLevel: float;
  54619. protected _sceneCenter: Vector3;
  54620. /**
  54621. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  54622. * It is usually zero but might be interesting to modify according to your setup.
  54623. */
  54624. sceneCenter: Vector3;
  54625. protected _opacityFresnel: boolean;
  54626. /**
  54627. * This helps specifying that the material is falling off to the sky box at grazing angle.
  54628. * This helps ensuring a nice transition when the camera goes under the ground.
  54629. */
  54630. opacityFresnel: boolean;
  54631. protected _reflectionFresnel: boolean;
  54632. /**
  54633. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  54634. * This helps adding a mirror texture on the ground.
  54635. */
  54636. reflectionFresnel: boolean;
  54637. protected _reflectionFalloffDistance: number;
  54638. /**
  54639. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  54640. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  54641. */
  54642. reflectionFalloffDistance: number;
  54643. protected _reflectionAmount: number;
  54644. /**
  54645. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  54646. */
  54647. reflectionAmount: number;
  54648. protected _reflectionReflectance0: number;
  54649. /**
  54650. * This specifies the weight of the reflection at grazing angle.
  54651. */
  54652. reflectionReflectance0: number;
  54653. protected _reflectionReflectance90: number;
  54654. /**
  54655. * This specifies the weight of the reflection at a perpendicular point of view.
  54656. */
  54657. reflectionReflectance90: number;
  54658. /**
  54659. * Sets the reflection reflectance fresnel values according to the default standard
  54660. * empirically know to work well :-)
  54661. */
  54662. set reflectionStandardFresnelWeight(value: number);
  54663. protected _useRGBColor: boolean;
  54664. /**
  54665. * Helps to directly use the maps channels instead of their level.
  54666. */
  54667. useRGBColor: boolean;
  54668. protected _enableNoise: boolean;
  54669. /**
  54670. * This helps reducing the banding effect that could occur on the background.
  54671. */
  54672. enableNoise: boolean;
  54673. /**
  54674. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54675. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  54676. * Recommended to be keep at 1.0 except for special cases.
  54677. */
  54678. get fovMultiplier(): number;
  54679. set fovMultiplier(value: number);
  54680. private _fovMultiplier;
  54681. /**
  54682. * Enable the FOV adjustment feature controlled by fovMultiplier.
  54683. */
  54684. useEquirectangularFOV: boolean;
  54685. private _maxSimultaneousLights;
  54686. /**
  54687. * Number of Simultaneous lights allowed on the material.
  54688. */
  54689. maxSimultaneousLights: int;
  54690. private _shadowOnly;
  54691. /**
  54692. * Make the material only render shadows
  54693. */
  54694. shadowOnly: boolean;
  54695. /**
  54696. * Default configuration related to image processing available in the Background Material.
  54697. */
  54698. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54699. /**
  54700. * Keep track of the image processing observer to allow dispose and replace.
  54701. */
  54702. private _imageProcessingObserver;
  54703. /**
  54704. * Attaches a new image processing configuration to the PBR Material.
  54705. * @param configuration (if null the scene configuration will be use)
  54706. */
  54707. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54708. /**
  54709. * Gets the image processing configuration used either in this material.
  54710. */
  54711. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  54712. /**
  54713. * Sets the Default image processing configuration used either in the this material.
  54714. *
  54715. * If sets to null, the scene one is in use.
  54716. */
  54717. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  54718. /**
  54719. * Gets wether the color curves effect is enabled.
  54720. */
  54721. get cameraColorCurvesEnabled(): boolean;
  54722. /**
  54723. * Sets wether the color curves effect is enabled.
  54724. */
  54725. set cameraColorCurvesEnabled(value: boolean);
  54726. /**
  54727. * Gets wether the color grading effect is enabled.
  54728. */
  54729. get cameraColorGradingEnabled(): boolean;
  54730. /**
  54731. * Gets wether the color grading effect is enabled.
  54732. */
  54733. set cameraColorGradingEnabled(value: boolean);
  54734. /**
  54735. * Gets wether tonemapping is enabled or not.
  54736. */
  54737. get cameraToneMappingEnabled(): boolean;
  54738. /**
  54739. * Sets wether tonemapping is enabled or not
  54740. */
  54741. set cameraToneMappingEnabled(value: boolean);
  54742. /**
  54743. * The camera exposure used on this material.
  54744. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54745. * This corresponds to a photographic exposure.
  54746. */
  54747. get cameraExposure(): float;
  54748. /**
  54749. * The camera exposure used on this material.
  54750. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54751. * This corresponds to a photographic exposure.
  54752. */
  54753. set cameraExposure(value: float);
  54754. /**
  54755. * Gets The camera contrast used on this material.
  54756. */
  54757. get cameraContrast(): float;
  54758. /**
  54759. * Sets The camera contrast used on this material.
  54760. */
  54761. set cameraContrast(value: float);
  54762. /**
  54763. * Gets the Color Grading 2D Lookup Texture.
  54764. */
  54765. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54766. /**
  54767. * Sets the Color Grading 2D Lookup Texture.
  54768. */
  54769. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54770. /**
  54771. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54772. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54773. * 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;
  54774. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54775. */
  54776. get cameraColorCurves(): Nullable<ColorCurves>;
  54777. /**
  54778. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54779. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54780. * 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;
  54781. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54782. */
  54783. set cameraColorCurves(value: Nullable<ColorCurves>);
  54784. /**
  54785. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  54786. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  54787. */
  54788. switchToBGR: boolean;
  54789. private _renderTargets;
  54790. private _reflectionControls;
  54791. private _white;
  54792. private _primaryShadowColor;
  54793. private _primaryHighlightColor;
  54794. /**
  54795. * Instantiates a Background Material in the given scene
  54796. * @param name The friendly name of the material
  54797. * @param scene The scene to add the material to
  54798. */
  54799. constructor(name: string, scene: Scene);
  54800. /**
  54801. * Gets a boolean indicating that current material needs to register RTT
  54802. */
  54803. get hasRenderTargetTextures(): boolean;
  54804. /**
  54805. * The entire material has been created in order to prevent overdraw.
  54806. * @returns false
  54807. */
  54808. needAlphaTesting(): boolean;
  54809. /**
  54810. * The entire material has been created in order to prevent overdraw.
  54811. * @returns true if blending is enable
  54812. */
  54813. needAlphaBlending(): boolean;
  54814. /**
  54815. * Checks wether the material is ready to be rendered for a given mesh.
  54816. * @param mesh The mesh to render
  54817. * @param subMesh The submesh to check against
  54818. * @param useInstances Specify wether or not the material is used with instances
  54819. * @returns true if all the dependencies are ready (Textures, Effects...)
  54820. */
  54821. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54822. /**
  54823. * Compute the primary color according to the chosen perceptual color.
  54824. */
  54825. private _computePrimaryColorFromPerceptualColor;
  54826. /**
  54827. * Compute the highlights and shadow colors according to their chosen levels.
  54828. */
  54829. private _computePrimaryColors;
  54830. /**
  54831. * Build the uniform buffer used in the material.
  54832. */
  54833. buildUniformLayout(): void;
  54834. /**
  54835. * Unbind the material.
  54836. */
  54837. unbind(): void;
  54838. /**
  54839. * Bind only the world matrix to the material.
  54840. * @param world The world matrix to bind.
  54841. */
  54842. bindOnlyWorldMatrix(world: Matrix): void;
  54843. /**
  54844. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  54845. * @param world The world matrix to bind.
  54846. * @param subMesh The submesh to bind for.
  54847. */
  54848. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54849. /**
  54850. * Checks to see if a texture is used in the material.
  54851. * @param texture - Base texture to use.
  54852. * @returns - Boolean specifying if a texture is used in the material.
  54853. */
  54854. hasTexture(texture: BaseTexture): boolean;
  54855. /**
  54856. * Dispose the material.
  54857. * @param forceDisposeEffect Force disposal of the associated effect.
  54858. * @param forceDisposeTextures Force disposal of the associated textures.
  54859. */
  54860. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  54861. /**
  54862. * Clones the material.
  54863. * @param name The cloned name.
  54864. * @returns The cloned material.
  54865. */
  54866. clone(name: string): BackgroundMaterial;
  54867. /**
  54868. * Serializes the current material to its JSON representation.
  54869. * @returns The JSON representation.
  54870. */
  54871. serialize(): any;
  54872. /**
  54873. * Gets the class name of the material
  54874. * @returns "BackgroundMaterial"
  54875. */
  54876. getClassName(): string;
  54877. /**
  54878. * Parse a JSON input to create back a background material.
  54879. * @param source The JSON data to parse
  54880. * @param scene The scene to create the parsed material in
  54881. * @param rootUrl The root url of the assets the material depends upon
  54882. * @returns the instantiated BackgroundMaterial.
  54883. */
  54884. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  54885. }
  54886. }
  54887. declare module BABYLON {
  54888. /**
  54889. * Represents the different options available during the creation of
  54890. * a Environment helper.
  54891. *
  54892. * This can control the default ground, skybox and image processing setup of your scene.
  54893. */
  54894. export interface IEnvironmentHelperOptions {
  54895. /**
  54896. * Specifies whether or not to create a ground.
  54897. * True by default.
  54898. */
  54899. createGround: boolean;
  54900. /**
  54901. * Specifies the ground size.
  54902. * 15 by default.
  54903. */
  54904. groundSize: number;
  54905. /**
  54906. * The texture used on the ground for the main color.
  54907. * Comes from the BabylonJS CDN by default.
  54908. *
  54909. * Remarks: Can be either a texture or a url.
  54910. */
  54911. groundTexture: string | BaseTexture;
  54912. /**
  54913. * The color mixed in the ground texture by default.
  54914. * BabylonJS clearColor by default.
  54915. */
  54916. groundColor: Color3;
  54917. /**
  54918. * Specifies the ground opacity.
  54919. * 1 by default.
  54920. */
  54921. groundOpacity: number;
  54922. /**
  54923. * Enables the ground to receive shadows.
  54924. * True by default.
  54925. */
  54926. enableGroundShadow: boolean;
  54927. /**
  54928. * Helps preventing the shadow to be fully black on the ground.
  54929. * 0.5 by default.
  54930. */
  54931. groundShadowLevel: number;
  54932. /**
  54933. * Creates a mirror texture attach to the ground.
  54934. * false by default.
  54935. */
  54936. enableGroundMirror: boolean;
  54937. /**
  54938. * Specifies the ground mirror size ratio.
  54939. * 0.3 by default as the default kernel is 64.
  54940. */
  54941. groundMirrorSizeRatio: number;
  54942. /**
  54943. * Specifies the ground mirror blur kernel size.
  54944. * 64 by default.
  54945. */
  54946. groundMirrorBlurKernel: number;
  54947. /**
  54948. * Specifies the ground mirror visibility amount.
  54949. * 1 by default
  54950. */
  54951. groundMirrorAmount: number;
  54952. /**
  54953. * Specifies the ground mirror reflectance weight.
  54954. * This uses the standard weight of the background material to setup the fresnel effect
  54955. * of the mirror.
  54956. * 1 by default.
  54957. */
  54958. groundMirrorFresnelWeight: number;
  54959. /**
  54960. * Specifies the ground mirror Falloff distance.
  54961. * This can helps reducing the size of the reflection.
  54962. * 0 by Default.
  54963. */
  54964. groundMirrorFallOffDistance: number;
  54965. /**
  54966. * Specifies the ground mirror texture type.
  54967. * Unsigned Int by Default.
  54968. */
  54969. groundMirrorTextureType: number;
  54970. /**
  54971. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  54972. * the shown objects.
  54973. */
  54974. groundYBias: number;
  54975. /**
  54976. * Specifies whether or not to create a skybox.
  54977. * True by default.
  54978. */
  54979. createSkybox: boolean;
  54980. /**
  54981. * Specifies the skybox size.
  54982. * 20 by default.
  54983. */
  54984. skyboxSize: number;
  54985. /**
  54986. * The texture used on the skybox for the main color.
  54987. * Comes from the BabylonJS CDN by default.
  54988. *
  54989. * Remarks: Can be either a texture or a url.
  54990. */
  54991. skyboxTexture: string | BaseTexture;
  54992. /**
  54993. * The color mixed in the skybox texture by default.
  54994. * BabylonJS clearColor by default.
  54995. */
  54996. skyboxColor: Color3;
  54997. /**
  54998. * The background rotation around the Y axis of the scene.
  54999. * This helps aligning the key lights of your scene with the background.
  55000. * 0 by default.
  55001. */
  55002. backgroundYRotation: number;
  55003. /**
  55004. * Compute automatically the size of the elements to best fit with the scene.
  55005. */
  55006. sizeAuto: boolean;
  55007. /**
  55008. * Default position of the rootMesh if autoSize is not true.
  55009. */
  55010. rootPosition: Vector3;
  55011. /**
  55012. * Sets up the image processing in the scene.
  55013. * true by default.
  55014. */
  55015. setupImageProcessing: boolean;
  55016. /**
  55017. * The texture used as your environment texture in the scene.
  55018. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  55019. *
  55020. * Remarks: Can be either a texture or a url.
  55021. */
  55022. environmentTexture: string | BaseTexture;
  55023. /**
  55024. * The value of the exposure to apply to the scene.
  55025. * 0.6 by default if setupImageProcessing is true.
  55026. */
  55027. cameraExposure: number;
  55028. /**
  55029. * The value of the contrast to apply to the scene.
  55030. * 1.6 by default if setupImageProcessing is true.
  55031. */
  55032. cameraContrast: number;
  55033. /**
  55034. * Specifies whether or not tonemapping should be enabled in the scene.
  55035. * true by default if setupImageProcessing is true.
  55036. */
  55037. toneMappingEnabled: boolean;
  55038. }
  55039. /**
  55040. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  55041. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  55042. * It also helps with the default setup of your imageProcessing configuration.
  55043. */
  55044. export class EnvironmentHelper {
  55045. /**
  55046. * Default ground texture URL.
  55047. */
  55048. private static _groundTextureCDNUrl;
  55049. /**
  55050. * Default skybox texture URL.
  55051. */
  55052. private static _skyboxTextureCDNUrl;
  55053. /**
  55054. * Default environment texture URL.
  55055. */
  55056. private static _environmentTextureCDNUrl;
  55057. /**
  55058. * Creates the default options for the helper.
  55059. */
  55060. private static _getDefaultOptions;
  55061. private _rootMesh;
  55062. /**
  55063. * Gets the root mesh created by the helper.
  55064. */
  55065. get rootMesh(): Mesh;
  55066. private _skybox;
  55067. /**
  55068. * Gets the skybox created by the helper.
  55069. */
  55070. get skybox(): Nullable<Mesh>;
  55071. private _skyboxTexture;
  55072. /**
  55073. * Gets the skybox texture created by the helper.
  55074. */
  55075. get skyboxTexture(): Nullable<BaseTexture>;
  55076. private _skyboxMaterial;
  55077. /**
  55078. * Gets the skybox material created by the helper.
  55079. */
  55080. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  55081. private _ground;
  55082. /**
  55083. * Gets the ground mesh created by the helper.
  55084. */
  55085. get ground(): Nullable<Mesh>;
  55086. private _groundTexture;
  55087. /**
  55088. * Gets the ground texture created by the helper.
  55089. */
  55090. get groundTexture(): Nullable<BaseTexture>;
  55091. private _groundMirror;
  55092. /**
  55093. * Gets the ground mirror created by the helper.
  55094. */
  55095. get groundMirror(): Nullable<MirrorTexture>;
  55096. /**
  55097. * Gets the ground mirror render list to helps pushing the meshes
  55098. * you wish in the ground reflection.
  55099. */
  55100. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  55101. private _groundMaterial;
  55102. /**
  55103. * Gets the ground material created by the helper.
  55104. */
  55105. get groundMaterial(): Nullable<BackgroundMaterial>;
  55106. /**
  55107. * Stores the creation options.
  55108. */
  55109. private readonly _scene;
  55110. private _options;
  55111. /**
  55112. * This observable will be notified with any error during the creation of the environment,
  55113. * mainly texture creation errors.
  55114. */
  55115. onErrorObservable: Observable<{
  55116. message?: string;
  55117. exception?: any;
  55118. }>;
  55119. /**
  55120. * constructor
  55121. * @param options Defines the options we want to customize the helper
  55122. * @param scene The scene to add the material to
  55123. */
  55124. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  55125. /**
  55126. * Updates the background according to the new options
  55127. * @param options
  55128. */
  55129. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  55130. /**
  55131. * Sets the primary color of all the available elements.
  55132. * @param color the main color to affect to the ground and the background
  55133. */
  55134. setMainColor(color: Color3): void;
  55135. /**
  55136. * Setup the image processing according to the specified options.
  55137. */
  55138. private _setupImageProcessing;
  55139. /**
  55140. * Setup the environment texture according to the specified options.
  55141. */
  55142. private _setupEnvironmentTexture;
  55143. /**
  55144. * Setup the background according to the specified options.
  55145. */
  55146. private _setupBackground;
  55147. /**
  55148. * Get the scene sizes according to the setup.
  55149. */
  55150. private _getSceneSize;
  55151. /**
  55152. * Setup the ground according to the specified options.
  55153. */
  55154. private _setupGround;
  55155. /**
  55156. * Setup the ground material according to the specified options.
  55157. */
  55158. private _setupGroundMaterial;
  55159. /**
  55160. * Setup the ground diffuse texture according to the specified options.
  55161. */
  55162. private _setupGroundDiffuseTexture;
  55163. /**
  55164. * Setup the ground mirror texture according to the specified options.
  55165. */
  55166. private _setupGroundMirrorTexture;
  55167. /**
  55168. * Setup the ground to receive the mirror texture.
  55169. */
  55170. private _setupMirrorInGroundMaterial;
  55171. /**
  55172. * Setup the skybox according to the specified options.
  55173. */
  55174. private _setupSkybox;
  55175. /**
  55176. * Setup the skybox material according to the specified options.
  55177. */
  55178. private _setupSkyboxMaterial;
  55179. /**
  55180. * Setup the skybox reflection texture according to the specified options.
  55181. */
  55182. private _setupSkyboxReflectionTexture;
  55183. private _errorHandler;
  55184. /**
  55185. * Dispose all the elements created by the Helper.
  55186. */
  55187. dispose(): void;
  55188. }
  55189. }
  55190. declare module BABYLON {
  55191. /**
  55192. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  55193. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  55194. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  55195. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55196. */
  55197. export abstract class TextureDome<T extends Texture> extends TransformNode {
  55198. protected onError: Nullable<(message?: string, exception?: any) => void>;
  55199. /**
  55200. * Define the source as a Monoscopic panoramic 360/180.
  55201. */
  55202. static readonly MODE_MONOSCOPIC: number;
  55203. /**
  55204. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  55205. */
  55206. static readonly MODE_TOPBOTTOM: number;
  55207. /**
  55208. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  55209. */
  55210. static readonly MODE_SIDEBYSIDE: number;
  55211. private _halfDome;
  55212. protected _useDirectMapping: boolean;
  55213. /**
  55214. * The texture being displayed on the sphere
  55215. */
  55216. protected _texture: T;
  55217. /**
  55218. * Gets the texture being displayed on the sphere
  55219. */
  55220. get texture(): T;
  55221. /**
  55222. * Sets the texture being displayed on the sphere
  55223. */
  55224. set texture(newTexture: T);
  55225. /**
  55226. * The skybox material
  55227. */
  55228. protected _material: BackgroundMaterial;
  55229. /**
  55230. * The surface used for the dome
  55231. */
  55232. protected _mesh: Mesh;
  55233. /**
  55234. * Gets the mesh used for the dome.
  55235. */
  55236. get mesh(): Mesh;
  55237. /**
  55238. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  55239. */
  55240. private _halfDomeMask;
  55241. /**
  55242. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55243. * Also see the options.resolution property.
  55244. */
  55245. get fovMultiplier(): number;
  55246. set fovMultiplier(value: number);
  55247. protected _textureMode: number;
  55248. /**
  55249. * Gets or set the current texture mode for the texture. It can be:
  55250. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55251. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55252. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55253. */
  55254. get textureMode(): number;
  55255. /**
  55256. * Sets the current texture mode for the texture. It can be:
  55257. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55258. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55259. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55260. */
  55261. set textureMode(value: number);
  55262. /**
  55263. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  55264. */
  55265. get halfDome(): boolean;
  55266. /**
  55267. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  55268. */
  55269. set halfDome(enabled: boolean);
  55270. /**
  55271. * Oberserver used in Stereoscopic VR Mode.
  55272. */
  55273. private _onBeforeCameraRenderObserver;
  55274. /**
  55275. * Observable raised when an error occured while loading the 360 image
  55276. */
  55277. onLoadErrorObservable: Observable<string>;
  55278. /**
  55279. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  55280. * @param name Element's name, child elements will append suffixes for their own names.
  55281. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  55282. * @param options An object containing optional or exposed sub element properties
  55283. */
  55284. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  55285. resolution?: number;
  55286. clickToPlay?: boolean;
  55287. autoPlay?: boolean;
  55288. loop?: boolean;
  55289. size?: number;
  55290. poster?: string;
  55291. faceForward?: boolean;
  55292. useDirectMapping?: boolean;
  55293. halfDomeMode?: boolean;
  55294. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  55295. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  55296. protected _changeTextureMode(value: number): void;
  55297. /**
  55298. * Releases resources associated with this node.
  55299. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  55300. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  55301. */
  55302. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  55303. }
  55304. }
  55305. declare module BABYLON {
  55306. /**
  55307. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  55308. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  55309. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  55310. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55311. */
  55312. export class PhotoDome extends TextureDome<Texture> {
  55313. /**
  55314. * Define the image as a Monoscopic panoramic 360 image.
  55315. */
  55316. static readonly MODE_MONOSCOPIC: number;
  55317. /**
  55318. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  55319. */
  55320. static readonly MODE_TOPBOTTOM: number;
  55321. /**
  55322. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  55323. */
  55324. static readonly MODE_SIDEBYSIDE: number;
  55325. /**
  55326. * Gets or sets the texture being displayed on the sphere
  55327. */
  55328. get photoTexture(): Texture;
  55329. /**
  55330. * sets the texture being displayed on the sphere
  55331. */
  55332. set photoTexture(value: Texture);
  55333. /**
  55334. * Gets the current video mode for the video. It can be:
  55335. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55336. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55337. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55338. */
  55339. get imageMode(): number;
  55340. /**
  55341. * Sets the current video mode for the video. It can be:
  55342. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55343. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55344. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55345. */
  55346. set imageMode(value: number);
  55347. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  55348. }
  55349. }
  55350. declare module BABYLON {
  55351. /**
  55352. * Class used to host RGBD texture specific utilities
  55353. */
  55354. export class RGBDTextureTools {
  55355. /**
  55356. * Expand the RGBD Texture from RGBD to Half Float if possible.
  55357. * @param texture the texture to expand.
  55358. */
  55359. static ExpandRGBDTexture(texture: Texture): void;
  55360. }
  55361. }
  55362. declare module BABYLON {
  55363. /**
  55364. * Class used to host texture specific utilities
  55365. */
  55366. export class BRDFTextureTools {
  55367. /**
  55368. * Prevents texture cache collision
  55369. */
  55370. private static _instanceNumber;
  55371. /**
  55372. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  55373. * @param scene defines the hosting scene
  55374. * @returns the environment BRDF texture
  55375. */
  55376. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  55377. private static _environmentBRDFBase64Texture;
  55378. }
  55379. }
  55380. declare module BABYLON {
  55381. /**
  55382. * @hidden
  55383. */
  55384. export interface IMaterialClearCoatDefines {
  55385. CLEARCOAT: boolean;
  55386. CLEARCOAT_DEFAULTIOR: boolean;
  55387. CLEARCOAT_TEXTURE: boolean;
  55388. CLEARCOAT_TEXTUREDIRECTUV: number;
  55389. CLEARCOAT_BUMP: boolean;
  55390. CLEARCOAT_BUMPDIRECTUV: number;
  55391. CLEARCOAT_TINT: boolean;
  55392. CLEARCOAT_TINT_TEXTURE: boolean;
  55393. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  55394. /** @hidden */
  55395. _areTexturesDirty: boolean;
  55396. }
  55397. /**
  55398. * Define the code related to the clear coat parameters of the pbr material.
  55399. */
  55400. export class PBRClearCoatConfiguration {
  55401. /**
  55402. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  55403. * The default fits with a polyurethane material.
  55404. */
  55405. private static readonly _DefaultIndexOfRefraction;
  55406. private _isEnabled;
  55407. /**
  55408. * Defines if the clear coat is enabled in the material.
  55409. */
  55410. isEnabled: boolean;
  55411. /**
  55412. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  55413. */
  55414. intensity: number;
  55415. /**
  55416. * Defines the clear coat layer roughness.
  55417. */
  55418. roughness: number;
  55419. private _indexOfRefraction;
  55420. /**
  55421. * Defines the index of refraction of the clear coat.
  55422. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  55423. * The default fits with a polyurethane material.
  55424. * Changing the default value is more performance intensive.
  55425. */
  55426. indexOfRefraction: number;
  55427. private _texture;
  55428. /**
  55429. * Stores the clear coat values in a texture.
  55430. */
  55431. texture: Nullable<BaseTexture>;
  55432. private _bumpTexture;
  55433. /**
  55434. * Define the clear coat specific bump texture.
  55435. */
  55436. bumpTexture: Nullable<BaseTexture>;
  55437. private _isTintEnabled;
  55438. /**
  55439. * Defines if the clear coat tint is enabled in the material.
  55440. */
  55441. isTintEnabled: boolean;
  55442. /**
  55443. * Defines the clear coat tint of the material.
  55444. * This is only use if tint is enabled
  55445. */
  55446. tintColor: Color3;
  55447. /**
  55448. * Defines the distance at which the tint color should be found in the
  55449. * clear coat media.
  55450. * This is only use if tint is enabled
  55451. */
  55452. tintColorAtDistance: number;
  55453. /**
  55454. * Defines the clear coat layer thickness.
  55455. * This is only use if tint is enabled
  55456. */
  55457. tintThickness: number;
  55458. private _tintTexture;
  55459. /**
  55460. * Stores the clear tint values in a texture.
  55461. * rgb is tint
  55462. * a is a thickness factor
  55463. */
  55464. tintTexture: Nullable<BaseTexture>;
  55465. /** @hidden */
  55466. private _internalMarkAllSubMeshesAsTexturesDirty;
  55467. /** @hidden */
  55468. _markAllSubMeshesAsTexturesDirty(): void;
  55469. /**
  55470. * Instantiate a new istance of clear coat configuration.
  55471. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55472. */
  55473. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55474. /**
  55475. * Gets wehter the submesh is ready to be used or not.
  55476. * @param defines the list of "defines" to update.
  55477. * @param scene defines the scene the material belongs to.
  55478. * @param engine defines the engine the material belongs to.
  55479. * @param disableBumpMap defines wether the material disables bump or not.
  55480. * @returns - boolean indicating that the submesh is ready or not.
  55481. */
  55482. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  55483. /**
  55484. * Checks to see if a texture is used in the material.
  55485. * @param defines the list of "defines" to update.
  55486. * @param scene defines the scene to the material belongs to.
  55487. */
  55488. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  55489. /**
  55490. * Binds the material data.
  55491. * @param uniformBuffer defines the Uniform buffer to fill in.
  55492. * @param scene defines the scene the material belongs to.
  55493. * @param engine defines the engine the material belongs to.
  55494. * @param disableBumpMap defines wether the material disables bump or not.
  55495. * @param isFrozen defines wether the material is frozen or not.
  55496. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  55497. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  55498. */
  55499. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  55500. /**
  55501. * Checks to see if a texture is used in the material.
  55502. * @param texture - Base texture to use.
  55503. * @returns - Boolean specifying if a texture is used in the material.
  55504. */
  55505. hasTexture(texture: BaseTexture): boolean;
  55506. /**
  55507. * Returns an array of the actively used textures.
  55508. * @param activeTextures Array of BaseTextures
  55509. */
  55510. getActiveTextures(activeTextures: BaseTexture[]): void;
  55511. /**
  55512. * Returns the animatable textures.
  55513. * @param animatables Array of animatable textures.
  55514. */
  55515. getAnimatables(animatables: IAnimatable[]): void;
  55516. /**
  55517. * Disposes the resources of the material.
  55518. * @param forceDisposeTextures - Forces the disposal of all textures.
  55519. */
  55520. dispose(forceDisposeTextures?: boolean): void;
  55521. /**
  55522. * Get the current class name of the texture useful for serialization or dynamic coding.
  55523. * @returns "PBRClearCoatConfiguration"
  55524. */
  55525. getClassName(): string;
  55526. /**
  55527. * Add fallbacks to the effect fallbacks list.
  55528. * @param defines defines the Base texture to use.
  55529. * @param fallbacks defines the current fallback list.
  55530. * @param currentRank defines the current fallback rank.
  55531. * @returns the new fallback rank.
  55532. */
  55533. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55534. /**
  55535. * Add the required uniforms to the current list.
  55536. * @param uniforms defines the current uniform list.
  55537. */
  55538. static AddUniforms(uniforms: string[]): void;
  55539. /**
  55540. * Add the required samplers to the current list.
  55541. * @param samplers defines the current sampler list.
  55542. */
  55543. static AddSamplers(samplers: string[]): void;
  55544. /**
  55545. * Add the required uniforms to the current buffer.
  55546. * @param uniformBuffer defines the current uniform buffer.
  55547. */
  55548. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55549. /**
  55550. * Makes a duplicate of the current configuration into another one.
  55551. * @param clearCoatConfiguration define the config where to copy the info
  55552. */
  55553. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  55554. /**
  55555. * Serializes this clear coat configuration.
  55556. * @returns - An object with the serialized config.
  55557. */
  55558. serialize(): any;
  55559. /**
  55560. * Parses a anisotropy Configuration from a serialized object.
  55561. * @param source - Serialized object.
  55562. * @param scene Defines the scene we are parsing for
  55563. * @param rootUrl Defines the rootUrl to load from
  55564. */
  55565. parse(source: any, scene: Scene, rootUrl: string): void;
  55566. }
  55567. }
  55568. declare module BABYLON {
  55569. /**
  55570. * @hidden
  55571. */
  55572. export interface IMaterialAnisotropicDefines {
  55573. ANISOTROPIC: boolean;
  55574. ANISOTROPIC_TEXTURE: boolean;
  55575. ANISOTROPIC_TEXTUREDIRECTUV: number;
  55576. MAINUV1: boolean;
  55577. _areTexturesDirty: boolean;
  55578. _needUVs: boolean;
  55579. }
  55580. /**
  55581. * Define the code related to the anisotropic parameters of the pbr material.
  55582. */
  55583. export class PBRAnisotropicConfiguration {
  55584. private _isEnabled;
  55585. /**
  55586. * Defines if the anisotropy is enabled in the material.
  55587. */
  55588. isEnabled: boolean;
  55589. /**
  55590. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  55591. */
  55592. intensity: number;
  55593. /**
  55594. * Defines if the effect is along the tangents, bitangents or in between.
  55595. * By default, the effect is "strectching" the highlights along the tangents.
  55596. */
  55597. direction: Vector2;
  55598. private _texture;
  55599. /**
  55600. * Stores the anisotropy values in a texture.
  55601. * rg is direction (like normal from -1 to 1)
  55602. * b is a intensity
  55603. */
  55604. texture: Nullable<BaseTexture>;
  55605. /** @hidden */
  55606. private _internalMarkAllSubMeshesAsTexturesDirty;
  55607. /** @hidden */
  55608. _markAllSubMeshesAsTexturesDirty(): void;
  55609. /**
  55610. * Instantiate a new istance of anisotropy configuration.
  55611. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55612. */
  55613. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55614. /**
  55615. * Specifies that the submesh is ready to be used.
  55616. * @param defines the list of "defines" to update.
  55617. * @param scene defines the scene the material belongs to.
  55618. * @returns - boolean indicating that the submesh is ready or not.
  55619. */
  55620. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  55621. /**
  55622. * Checks to see if a texture is used in the material.
  55623. * @param defines the list of "defines" to update.
  55624. * @param mesh the mesh we are preparing the defines for.
  55625. * @param scene defines the scene the material belongs to.
  55626. */
  55627. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  55628. /**
  55629. * Binds the material data.
  55630. * @param uniformBuffer defines the Uniform buffer to fill in.
  55631. * @param scene defines the scene the material belongs to.
  55632. * @param isFrozen defines wether the material is frozen or not.
  55633. */
  55634. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  55635. /**
  55636. * Checks to see if a texture is used in the material.
  55637. * @param texture - Base texture to use.
  55638. * @returns - Boolean specifying if a texture is used in the material.
  55639. */
  55640. hasTexture(texture: BaseTexture): boolean;
  55641. /**
  55642. * Returns an array of the actively used textures.
  55643. * @param activeTextures Array of BaseTextures
  55644. */
  55645. getActiveTextures(activeTextures: BaseTexture[]): void;
  55646. /**
  55647. * Returns the animatable textures.
  55648. * @param animatables Array of animatable textures.
  55649. */
  55650. getAnimatables(animatables: IAnimatable[]): void;
  55651. /**
  55652. * Disposes the resources of the material.
  55653. * @param forceDisposeTextures - Forces the disposal of all textures.
  55654. */
  55655. dispose(forceDisposeTextures?: boolean): void;
  55656. /**
  55657. * Get the current class name of the texture useful for serialization or dynamic coding.
  55658. * @returns "PBRAnisotropicConfiguration"
  55659. */
  55660. getClassName(): string;
  55661. /**
  55662. * Add fallbacks to the effect fallbacks list.
  55663. * @param defines defines the Base texture to use.
  55664. * @param fallbacks defines the current fallback list.
  55665. * @param currentRank defines the current fallback rank.
  55666. * @returns the new fallback rank.
  55667. */
  55668. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55669. /**
  55670. * Add the required uniforms to the current list.
  55671. * @param uniforms defines the current uniform list.
  55672. */
  55673. static AddUniforms(uniforms: string[]): void;
  55674. /**
  55675. * Add the required uniforms to the current buffer.
  55676. * @param uniformBuffer defines the current uniform buffer.
  55677. */
  55678. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55679. /**
  55680. * Add the required samplers to the current list.
  55681. * @param samplers defines the current sampler list.
  55682. */
  55683. static AddSamplers(samplers: string[]): void;
  55684. /**
  55685. * Makes a duplicate of the current configuration into another one.
  55686. * @param anisotropicConfiguration define the config where to copy the info
  55687. */
  55688. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  55689. /**
  55690. * Serializes this anisotropy configuration.
  55691. * @returns - An object with the serialized config.
  55692. */
  55693. serialize(): any;
  55694. /**
  55695. * Parses a anisotropy Configuration from a serialized object.
  55696. * @param source - Serialized object.
  55697. * @param scene Defines the scene we are parsing for
  55698. * @param rootUrl Defines the rootUrl to load from
  55699. */
  55700. parse(source: any, scene: Scene, rootUrl: string): void;
  55701. }
  55702. }
  55703. declare module BABYLON {
  55704. /**
  55705. * @hidden
  55706. */
  55707. export interface IMaterialBRDFDefines {
  55708. BRDF_V_HEIGHT_CORRELATED: boolean;
  55709. MS_BRDF_ENERGY_CONSERVATION: boolean;
  55710. SPHERICAL_HARMONICS: boolean;
  55711. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  55712. /** @hidden */
  55713. _areMiscDirty: boolean;
  55714. }
  55715. /**
  55716. * Define the code related to the BRDF parameters of the pbr material.
  55717. */
  55718. export class PBRBRDFConfiguration {
  55719. /**
  55720. * Default value used for the energy conservation.
  55721. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  55722. */
  55723. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  55724. /**
  55725. * Default value used for the Smith Visibility Height Correlated mode.
  55726. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  55727. */
  55728. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  55729. /**
  55730. * Default value used for the IBL diffuse part.
  55731. * This can help switching back to the polynomials mode globally which is a tiny bit
  55732. * less GPU intensive at the drawback of a lower quality.
  55733. */
  55734. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  55735. /**
  55736. * Default value used for activating energy conservation for the specular workflow.
  55737. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  55738. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  55739. */
  55740. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  55741. private _useEnergyConservation;
  55742. /**
  55743. * Defines if the material uses energy conservation.
  55744. */
  55745. useEnergyConservation: boolean;
  55746. private _useSmithVisibilityHeightCorrelated;
  55747. /**
  55748. * LEGACY Mode set to false
  55749. * Defines if the material uses height smith correlated visibility term.
  55750. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  55751. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  55752. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  55753. * Not relying on height correlated will also disable energy conservation.
  55754. */
  55755. useSmithVisibilityHeightCorrelated: boolean;
  55756. private _useSphericalHarmonics;
  55757. /**
  55758. * LEGACY Mode set to false
  55759. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  55760. * diffuse part of the IBL.
  55761. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  55762. * to the ground truth.
  55763. */
  55764. useSphericalHarmonics: boolean;
  55765. private _useSpecularGlossinessInputEnergyConservation;
  55766. /**
  55767. * Defines if the material uses energy conservation, when the specular workflow is active.
  55768. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  55769. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  55770. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  55771. */
  55772. useSpecularGlossinessInputEnergyConservation: boolean;
  55773. /** @hidden */
  55774. private _internalMarkAllSubMeshesAsMiscDirty;
  55775. /** @hidden */
  55776. _markAllSubMeshesAsMiscDirty(): void;
  55777. /**
  55778. * Instantiate a new istance of clear coat configuration.
  55779. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  55780. */
  55781. constructor(markAllSubMeshesAsMiscDirty: () => void);
  55782. /**
  55783. * Checks to see if a texture is used in the material.
  55784. * @param defines the list of "defines" to update.
  55785. */
  55786. prepareDefines(defines: IMaterialBRDFDefines): void;
  55787. /**
  55788. * Get the current class name of the texture useful for serialization or dynamic coding.
  55789. * @returns "PBRClearCoatConfiguration"
  55790. */
  55791. getClassName(): string;
  55792. /**
  55793. * Makes a duplicate of the current configuration into another one.
  55794. * @param brdfConfiguration define the config where to copy the info
  55795. */
  55796. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  55797. /**
  55798. * Serializes this BRDF configuration.
  55799. * @returns - An object with the serialized config.
  55800. */
  55801. serialize(): any;
  55802. /**
  55803. * Parses a anisotropy Configuration from a serialized object.
  55804. * @param source - Serialized object.
  55805. * @param scene Defines the scene we are parsing for
  55806. * @param rootUrl Defines the rootUrl to load from
  55807. */
  55808. parse(source: any, scene: Scene, rootUrl: string): void;
  55809. }
  55810. }
  55811. declare module BABYLON {
  55812. /**
  55813. * @hidden
  55814. */
  55815. export interface IMaterialSheenDefines {
  55816. SHEEN: boolean;
  55817. SHEEN_TEXTURE: boolean;
  55818. SHEEN_TEXTUREDIRECTUV: number;
  55819. SHEEN_LINKWITHALBEDO: boolean;
  55820. SHEEN_ROUGHNESS: boolean;
  55821. SHEEN_ALBEDOSCALING: boolean;
  55822. /** @hidden */
  55823. _areTexturesDirty: boolean;
  55824. }
  55825. /**
  55826. * Define the code related to the Sheen parameters of the pbr material.
  55827. */
  55828. export class PBRSheenConfiguration {
  55829. private _isEnabled;
  55830. /**
  55831. * Defines if the material uses sheen.
  55832. */
  55833. isEnabled: boolean;
  55834. private _linkSheenWithAlbedo;
  55835. /**
  55836. * Defines if the sheen is linked to the sheen color.
  55837. */
  55838. linkSheenWithAlbedo: boolean;
  55839. /**
  55840. * Defines the sheen intensity.
  55841. */
  55842. intensity: number;
  55843. /**
  55844. * Defines the sheen color.
  55845. */
  55846. color: Color3;
  55847. private _texture;
  55848. /**
  55849. * Stores the sheen tint values in a texture.
  55850. * rgb is tint
  55851. * a is a intensity or roughness if roughness has been defined
  55852. */
  55853. texture: Nullable<BaseTexture>;
  55854. private _roughness;
  55855. /**
  55856. * Defines the sheen roughness.
  55857. * It is not taken into account if linkSheenWithAlbedo is true.
  55858. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  55859. */
  55860. roughness: Nullable<number>;
  55861. private _albedoScaling;
  55862. /**
  55863. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  55864. * It allows the strength of the sheen effect to not depend on the base color of the material,
  55865. * making it easier to setup and tweak the effect
  55866. */
  55867. albedoScaling: boolean;
  55868. /** @hidden */
  55869. private _internalMarkAllSubMeshesAsTexturesDirty;
  55870. /** @hidden */
  55871. _markAllSubMeshesAsTexturesDirty(): void;
  55872. /**
  55873. * Instantiate a new istance of clear coat configuration.
  55874. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55875. */
  55876. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55877. /**
  55878. * Specifies that the submesh is ready to be used.
  55879. * @param defines the list of "defines" to update.
  55880. * @param scene defines the scene the material belongs to.
  55881. * @returns - boolean indicating that the submesh is ready or not.
  55882. */
  55883. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  55884. /**
  55885. * Checks to see if a texture is used in the material.
  55886. * @param defines the list of "defines" to update.
  55887. * @param scene defines the scene the material belongs to.
  55888. */
  55889. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  55890. /**
  55891. * Binds the material data.
  55892. * @param uniformBuffer defines the Uniform buffer to fill in.
  55893. * @param scene defines the scene the material belongs to.
  55894. * @param isFrozen defines wether the material is frozen or not.
  55895. */
  55896. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  55897. /**
  55898. * Checks to see if a texture is used in the material.
  55899. * @param texture - Base texture to use.
  55900. * @returns - Boolean specifying if a texture is used in the material.
  55901. */
  55902. hasTexture(texture: BaseTexture): boolean;
  55903. /**
  55904. * Returns an array of the actively used textures.
  55905. * @param activeTextures Array of BaseTextures
  55906. */
  55907. getActiveTextures(activeTextures: BaseTexture[]): void;
  55908. /**
  55909. * Returns the animatable textures.
  55910. * @param animatables Array of animatable textures.
  55911. */
  55912. getAnimatables(animatables: IAnimatable[]): void;
  55913. /**
  55914. * Disposes the resources of the material.
  55915. * @param forceDisposeTextures - Forces the disposal of all textures.
  55916. */
  55917. dispose(forceDisposeTextures?: boolean): void;
  55918. /**
  55919. * Get the current class name of the texture useful for serialization or dynamic coding.
  55920. * @returns "PBRSheenConfiguration"
  55921. */
  55922. getClassName(): string;
  55923. /**
  55924. * Add fallbacks to the effect fallbacks list.
  55925. * @param defines defines the Base texture to use.
  55926. * @param fallbacks defines the current fallback list.
  55927. * @param currentRank defines the current fallback rank.
  55928. * @returns the new fallback rank.
  55929. */
  55930. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55931. /**
  55932. * Add the required uniforms to the current list.
  55933. * @param uniforms defines the current uniform list.
  55934. */
  55935. static AddUniforms(uniforms: string[]): void;
  55936. /**
  55937. * Add the required uniforms to the current buffer.
  55938. * @param uniformBuffer defines the current uniform buffer.
  55939. */
  55940. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55941. /**
  55942. * Add the required samplers to the current list.
  55943. * @param samplers defines the current sampler list.
  55944. */
  55945. static AddSamplers(samplers: string[]): void;
  55946. /**
  55947. * Makes a duplicate of the current configuration into another one.
  55948. * @param sheenConfiguration define the config where to copy the info
  55949. */
  55950. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  55951. /**
  55952. * Serializes this BRDF configuration.
  55953. * @returns - An object with the serialized config.
  55954. */
  55955. serialize(): any;
  55956. /**
  55957. * Parses a anisotropy Configuration from a serialized object.
  55958. * @param source - Serialized object.
  55959. * @param scene Defines the scene we are parsing for
  55960. * @param rootUrl Defines the rootUrl to load from
  55961. */
  55962. parse(source: any, scene: Scene, rootUrl: string): void;
  55963. }
  55964. }
  55965. declare module BABYLON {
  55966. /**
  55967. * @hidden
  55968. */
  55969. export interface IMaterialSubSurfaceDefines {
  55970. SUBSURFACE: boolean;
  55971. SS_REFRACTION: boolean;
  55972. SS_TRANSLUCENCY: boolean;
  55973. SS_SCATTERING: boolean;
  55974. SS_THICKNESSANDMASK_TEXTURE: boolean;
  55975. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  55976. SS_REFRACTIONMAP_3D: boolean;
  55977. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  55978. SS_LODINREFRACTIONALPHA: boolean;
  55979. SS_GAMMAREFRACTION: boolean;
  55980. SS_RGBDREFRACTION: boolean;
  55981. SS_LINEARSPECULARREFRACTION: boolean;
  55982. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  55983. SS_ALBEDOFORREFRACTIONTINT: boolean;
  55984. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  55985. /** @hidden */
  55986. _areTexturesDirty: boolean;
  55987. }
  55988. /**
  55989. * Define the code related to the sub surface parameters of the pbr material.
  55990. */
  55991. export class PBRSubSurfaceConfiguration {
  55992. private _isRefractionEnabled;
  55993. /**
  55994. * Defines if the refraction is enabled in the material.
  55995. */
  55996. isRefractionEnabled: boolean;
  55997. private _isTranslucencyEnabled;
  55998. /**
  55999. * Defines if the translucency is enabled in the material.
  56000. */
  56001. isTranslucencyEnabled: boolean;
  56002. private _isScatteringEnabled;
  56003. /**
  56004. * Defines if the sub surface scattering is enabled in the material.
  56005. */
  56006. isScatteringEnabled: boolean;
  56007. private _scatteringDiffusionProfileIndex;
  56008. /**
  56009. * Diffusion profile for subsurface scattering.
  56010. * Useful for better scattering in the skins or foliages.
  56011. */
  56012. get scatteringDiffusionProfile(): Nullable<Color3>;
  56013. set scatteringDiffusionProfile(c: Nullable<Color3>);
  56014. /**
  56015. * Defines the refraction intensity of the material.
  56016. * The refraction when enabled replaces the Diffuse part of the material.
  56017. * The intensity helps transitionning between diffuse and refraction.
  56018. */
  56019. refractionIntensity: number;
  56020. /**
  56021. * Defines the translucency intensity of the material.
  56022. * When translucency has been enabled, this defines how much of the "translucency"
  56023. * is addded to the diffuse part of the material.
  56024. */
  56025. translucencyIntensity: number;
  56026. /**
  56027. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  56028. */
  56029. useAlbedoToTintRefraction: boolean;
  56030. private _thicknessTexture;
  56031. /**
  56032. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  56033. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  56034. * 0 would mean minimumThickness
  56035. * 1 would mean maximumThickness
  56036. * The other channels might be use as a mask to vary the different effects intensity.
  56037. */
  56038. thicknessTexture: Nullable<BaseTexture>;
  56039. private _refractionTexture;
  56040. /**
  56041. * Defines the texture to use for refraction.
  56042. */
  56043. refractionTexture: Nullable<BaseTexture>;
  56044. private _indexOfRefraction;
  56045. /**
  56046. * Index of refraction of the material base layer.
  56047. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  56048. *
  56049. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  56050. *
  56051. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  56052. */
  56053. indexOfRefraction: number;
  56054. private _volumeIndexOfRefraction;
  56055. /**
  56056. * Index of refraction of the material's volume.
  56057. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  56058. *
  56059. * This ONLY impacts refraction. If not provided or given a non-valid value,
  56060. * the volume will use the same IOR as the surface.
  56061. */
  56062. get volumeIndexOfRefraction(): number;
  56063. set volumeIndexOfRefraction(value: number);
  56064. private _invertRefractionY;
  56065. /**
  56066. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  56067. */
  56068. invertRefractionY: boolean;
  56069. private _linkRefractionWithTransparency;
  56070. /**
  56071. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  56072. * Materials half opaque for instance using refraction could benefit from this control.
  56073. */
  56074. linkRefractionWithTransparency: boolean;
  56075. /**
  56076. * Defines the minimum thickness stored in the thickness map.
  56077. * If no thickness map is defined, this value will be used to simulate thickness.
  56078. */
  56079. minimumThickness: number;
  56080. /**
  56081. * Defines the maximum thickness stored in the thickness map.
  56082. */
  56083. maximumThickness: number;
  56084. /**
  56085. * Defines the volume tint of the material.
  56086. * This is used for both translucency and scattering.
  56087. */
  56088. tintColor: Color3;
  56089. /**
  56090. * Defines the distance at which the tint color should be found in the media.
  56091. * This is used for refraction only.
  56092. */
  56093. tintColorAtDistance: number;
  56094. /**
  56095. * Defines how far each channel transmit through the media.
  56096. * It is defined as a color to simplify it selection.
  56097. */
  56098. diffusionDistance: Color3;
  56099. private _useMaskFromThicknessTexture;
  56100. /**
  56101. * Stores the intensity of the different subsurface effects in the thickness texture.
  56102. * * the green channel is the translucency intensity.
  56103. * * the blue channel is the scattering intensity.
  56104. * * the alpha channel is the refraction intensity.
  56105. */
  56106. useMaskFromThicknessTexture: boolean;
  56107. private _scene;
  56108. /** @hidden */
  56109. private _internalMarkAllSubMeshesAsTexturesDirty;
  56110. private _internalMarkScenePrePassDirty;
  56111. /** @hidden */
  56112. _markAllSubMeshesAsTexturesDirty(): void;
  56113. /** @hidden */
  56114. _markScenePrePassDirty(): void;
  56115. /**
  56116. * Instantiate a new istance of sub surface configuration.
  56117. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56118. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  56119. * @param scene The scene
  56120. */
  56121. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  56122. /**
  56123. * Gets wehter the submesh is ready to be used or not.
  56124. * @param defines the list of "defines" to update.
  56125. * @param scene defines the scene the material belongs to.
  56126. * @returns - boolean indicating that the submesh is ready or not.
  56127. */
  56128. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  56129. /**
  56130. * Checks to see if a texture is used in the material.
  56131. * @param defines the list of "defines" to update.
  56132. * @param scene defines the scene to the material belongs to.
  56133. */
  56134. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  56135. /**
  56136. * Binds the material data.
  56137. * @param uniformBuffer defines the Uniform buffer to fill in.
  56138. * @param scene defines the scene the material belongs to.
  56139. * @param engine defines the engine the material belongs to.
  56140. * @param isFrozen defines whether the material is frozen or not.
  56141. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  56142. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  56143. */
  56144. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  56145. /**
  56146. * Unbinds the material from the mesh.
  56147. * @param activeEffect defines the effect that should be unbound from.
  56148. * @returns true if unbound, otherwise false
  56149. */
  56150. unbind(activeEffect: Effect): boolean;
  56151. /**
  56152. * Returns the texture used for refraction or null if none is used.
  56153. * @param scene defines the scene the material belongs to.
  56154. * @returns - Refraction texture if present. If no refraction texture and refraction
  56155. * is linked with transparency, returns environment texture. Otherwise, returns null.
  56156. */
  56157. private _getRefractionTexture;
  56158. /**
  56159. * Returns true if alpha blending should be disabled.
  56160. */
  56161. get disableAlphaBlending(): boolean;
  56162. /**
  56163. * Fills the list of render target textures.
  56164. * @param renderTargets the list of render targets to update
  56165. */
  56166. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  56167. /**
  56168. * Checks to see if a texture is used in the material.
  56169. * @param texture - Base texture to use.
  56170. * @returns - Boolean specifying if a texture is used in the material.
  56171. */
  56172. hasTexture(texture: BaseTexture): boolean;
  56173. /**
  56174. * Gets a boolean indicating that current material needs to register RTT
  56175. * @returns true if this uses a render target otherwise false.
  56176. */
  56177. hasRenderTargetTextures(): boolean;
  56178. /**
  56179. * Returns an array of the actively used textures.
  56180. * @param activeTextures Array of BaseTextures
  56181. */
  56182. getActiveTextures(activeTextures: BaseTexture[]): void;
  56183. /**
  56184. * Returns the animatable textures.
  56185. * @param animatables Array of animatable textures.
  56186. */
  56187. getAnimatables(animatables: IAnimatable[]): void;
  56188. /**
  56189. * Disposes the resources of the material.
  56190. * @param forceDisposeTextures - Forces the disposal of all textures.
  56191. */
  56192. dispose(forceDisposeTextures?: boolean): void;
  56193. /**
  56194. * Get the current class name of the texture useful for serialization or dynamic coding.
  56195. * @returns "PBRSubSurfaceConfiguration"
  56196. */
  56197. getClassName(): string;
  56198. /**
  56199. * Add fallbacks to the effect fallbacks list.
  56200. * @param defines defines the Base texture to use.
  56201. * @param fallbacks defines the current fallback list.
  56202. * @param currentRank defines the current fallback rank.
  56203. * @returns the new fallback rank.
  56204. */
  56205. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56206. /**
  56207. * Add the required uniforms to the current list.
  56208. * @param uniforms defines the current uniform list.
  56209. */
  56210. static AddUniforms(uniforms: string[]): void;
  56211. /**
  56212. * Add the required samplers to the current list.
  56213. * @param samplers defines the current sampler list.
  56214. */
  56215. static AddSamplers(samplers: string[]): void;
  56216. /**
  56217. * Add the required uniforms to the current buffer.
  56218. * @param uniformBuffer defines the current uniform buffer.
  56219. */
  56220. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56221. /**
  56222. * Makes a duplicate of the current configuration into another one.
  56223. * @param configuration define the config where to copy the info
  56224. */
  56225. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  56226. /**
  56227. * Serializes this Sub Surface configuration.
  56228. * @returns - An object with the serialized config.
  56229. */
  56230. serialize(): any;
  56231. /**
  56232. * Parses a anisotropy Configuration from a serialized object.
  56233. * @param source - Serialized object.
  56234. * @param scene Defines the scene we are parsing for
  56235. * @param rootUrl Defines the rootUrl to load from
  56236. */
  56237. parse(source: any, scene: Scene, rootUrl: string): void;
  56238. }
  56239. }
  56240. declare module BABYLON {
  56241. /** @hidden */
  56242. export var pbrFragmentDeclaration: {
  56243. name: string;
  56244. shader: string;
  56245. };
  56246. }
  56247. declare module BABYLON {
  56248. /** @hidden */
  56249. export var pbrUboDeclaration: {
  56250. name: string;
  56251. shader: string;
  56252. };
  56253. }
  56254. declare module BABYLON {
  56255. /** @hidden */
  56256. export var pbrFragmentExtraDeclaration: {
  56257. name: string;
  56258. shader: string;
  56259. };
  56260. }
  56261. declare module BABYLON {
  56262. /** @hidden */
  56263. export var pbrFragmentSamplersDeclaration: {
  56264. name: string;
  56265. shader: string;
  56266. };
  56267. }
  56268. declare module BABYLON {
  56269. /** @hidden */
  56270. export var subSurfaceScatteringFunctions: {
  56271. name: string;
  56272. shader: string;
  56273. };
  56274. }
  56275. declare module BABYLON {
  56276. /** @hidden */
  56277. export var importanceSampling: {
  56278. name: string;
  56279. shader: string;
  56280. };
  56281. }
  56282. declare module BABYLON {
  56283. /** @hidden */
  56284. export var pbrHelperFunctions: {
  56285. name: string;
  56286. shader: string;
  56287. };
  56288. }
  56289. declare module BABYLON {
  56290. /** @hidden */
  56291. export var harmonicsFunctions: {
  56292. name: string;
  56293. shader: string;
  56294. };
  56295. }
  56296. declare module BABYLON {
  56297. /** @hidden */
  56298. export var pbrDirectLightingSetupFunctions: {
  56299. name: string;
  56300. shader: string;
  56301. };
  56302. }
  56303. declare module BABYLON {
  56304. /** @hidden */
  56305. export var pbrDirectLightingFalloffFunctions: {
  56306. name: string;
  56307. shader: string;
  56308. };
  56309. }
  56310. declare module BABYLON {
  56311. /** @hidden */
  56312. export var pbrBRDFFunctions: {
  56313. name: string;
  56314. shader: string;
  56315. };
  56316. }
  56317. declare module BABYLON {
  56318. /** @hidden */
  56319. export var hdrFilteringFunctions: {
  56320. name: string;
  56321. shader: string;
  56322. };
  56323. }
  56324. declare module BABYLON {
  56325. /** @hidden */
  56326. export var pbrDirectLightingFunctions: {
  56327. name: string;
  56328. shader: string;
  56329. };
  56330. }
  56331. declare module BABYLON {
  56332. /** @hidden */
  56333. export var pbrIBLFunctions: {
  56334. name: string;
  56335. shader: string;
  56336. };
  56337. }
  56338. declare module BABYLON {
  56339. /** @hidden */
  56340. export var pbrBlockAlbedoOpacity: {
  56341. name: string;
  56342. shader: string;
  56343. };
  56344. }
  56345. declare module BABYLON {
  56346. /** @hidden */
  56347. export var pbrBlockReflectivity: {
  56348. name: string;
  56349. shader: string;
  56350. };
  56351. }
  56352. declare module BABYLON {
  56353. /** @hidden */
  56354. export var pbrBlockAmbientOcclusion: {
  56355. name: string;
  56356. shader: string;
  56357. };
  56358. }
  56359. declare module BABYLON {
  56360. /** @hidden */
  56361. export var pbrBlockAlphaFresnel: {
  56362. name: string;
  56363. shader: string;
  56364. };
  56365. }
  56366. declare module BABYLON {
  56367. /** @hidden */
  56368. export var pbrBlockAnisotropic: {
  56369. name: string;
  56370. shader: string;
  56371. };
  56372. }
  56373. declare module BABYLON {
  56374. /** @hidden */
  56375. export var pbrBlockReflection: {
  56376. name: string;
  56377. shader: string;
  56378. };
  56379. }
  56380. declare module BABYLON {
  56381. /** @hidden */
  56382. export var pbrBlockSheen: {
  56383. name: string;
  56384. shader: string;
  56385. };
  56386. }
  56387. declare module BABYLON {
  56388. /** @hidden */
  56389. export var pbrBlockClearcoat: {
  56390. name: string;
  56391. shader: string;
  56392. };
  56393. }
  56394. declare module BABYLON {
  56395. /** @hidden */
  56396. export var pbrBlockSubSurface: {
  56397. name: string;
  56398. shader: string;
  56399. };
  56400. }
  56401. declare module BABYLON {
  56402. /** @hidden */
  56403. export var pbrBlockNormalGeometric: {
  56404. name: string;
  56405. shader: string;
  56406. };
  56407. }
  56408. declare module BABYLON {
  56409. /** @hidden */
  56410. export var pbrBlockNormalFinal: {
  56411. name: string;
  56412. shader: string;
  56413. };
  56414. }
  56415. declare module BABYLON {
  56416. /** @hidden */
  56417. export var pbrBlockLightmapInit: {
  56418. name: string;
  56419. shader: string;
  56420. };
  56421. }
  56422. declare module BABYLON {
  56423. /** @hidden */
  56424. export var pbrBlockGeometryInfo: {
  56425. name: string;
  56426. shader: string;
  56427. };
  56428. }
  56429. declare module BABYLON {
  56430. /** @hidden */
  56431. export var pbrBlockReflectance0: {
  56432. name: string;
  56433. shader: string;
  56434. };
  56435. }
  56436. declare module BABYLON {
  56437. /** @hidden */
  56438. export var pbrBlockReflectance: {
  56439. name: string;
  56440. shader: string;
  56441. };
  56442. }
  56443. declare module BABYLON {
  56444. /** @hidden */
  56445. export var pbrBlockDirectLighting: {
  56446. name: string;
  56447. shader: string;
  56448. };
  56449. }
  56450. declare module BABYLON {
  56451. /** @hidden */
  56452. export var pbrBlockFinalLitComponents: {
  56453. name: string;
  56454. shader: string;
  56455. };
  56456. }
  56457. declare module BABYLON {
  56458. /** @hidden */
  56459. export var pbrBlockFinalUnlitComponents: {
  56460. name: string;
  56461. shader: string;
  56462. };
  56463. }
  56464. declare module BABYLON {
  56465. /** @hidden */
  56466. export var pbrBlockFinalColorComposition: {
  56467. name: string;
  56468. shader: string;
  56469. };
  56470. }
  56471. declare module BABYLON {
  56472. /** @hidden */
  56473. export var pbrBlockImageProcessing: {
  56474. name: string;
  56475. shader: string;
  56476. };
  56477. }
  56478. declare module BABYLON {
  56479. /** @hidden */
  56480. export var pbrDebug: {
  56481. name: string;
  56482. shader: string;
  56483. };
  56484. }
  56485. declare module BABYLON {
  56486. /** @hidden */
  56487. export var pbrPixelShader: {
  56488. name: string;
  56489. shader: string;
  56490. };
  56491. }
  56492. declare module BABYLON {
  56493. /** @hidden */
  56494. export var pbrVertexDeclaration: {
  56495. name: string;
  56496. shader: string;
  56497. };
  56498. }
  56499. declare module BABYLON {
  56500. /** @hidden */
  56501. export var pbrVertexShader: {
  56502. name: string;
  56503. shader: string;
  56504. };
  56505. }
  56506. declare module BABYLON {
  56507. /**
  56508. * Manages the defines for the PBR Material.
  56509. * @hidden
  56510. */
  56511. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  56512. PBR: boolean;
  56513. NUM_SAMPLES: string;
  56514. REALTIME_FILTERING: boolean;
  56515. MAINUV1: boolean;
  56516. MAINUV2: boolean;
  56517. UV1: boolean;
  56518. UV2: boolean;
  56519. ALBEDO: boolean;
  56520. GAMMAALBEDO: boolean;
  56521. ALBEDODIRECTUV: number;
  56522. VERTEXCOLOR: boolean;
  56523. DETAIL: boolean;
  56524. DETAILDIRECTUV: number;
  56525. DETAIL_NORMALBLENDMETHOD: number;
  56526. AMBIENT: boolean;
  56527. AMBIENTDIRECTUV: number;
  56528. AMBIENTINGRAYSCALE: boolean;
  56529. OPACITY: boolean;
  56530. VERTEXALPHA: boolean;
  56531. OPACITYDIRECTUV: number;
  56532. OPACITYRGB: boolean;
  56533. ALPHATEST: boolean;
  56534. DEPTHPREPASS: boolean;
  56535. ALPHABLEND: boolean;
  56536. ALPHAFROMALBEDO: boolean;
  56537. ALPHATESTVALUE: string;
  56538. SPECULAROVERALPHA: boolean;
  56539. RADIANCEOVERALPHA: boolean;
  56540. ALPHAFRESNEL: boolean;
  56541. LINEARALPHAFRESNEL: boolean;
  56542. PREMULTIPLYALPHA: boolean;
  56543. EMISSIVE: boolean;
  56544. EMISSIVEDIRECTUV: number;
  56545. REFLECTIVITY: boolean;
  56546. REFLECTIVITYDIRECTUV: number;
  56547. SPECULARTERM: boolean;
  56548. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  56549. MICROSURFACEAUTOMATIC: boolean;
  56550. LODBASEDMICROSFURACE: boolean;
  56551. MICROSURFACEMAP: boolean;
  56552. MICROSURFACEMAPDIRECTUV: number;
  56553. METALLICWORKFLOW: boolean;
  56554. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  56555. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  56556. METALLNESSSTOREINMETALMAPBLUE: boolean;
  56557. AOSTOREINMETALMAPRED: boolean;
  56558. METALLIC_REFLECTANCE: boolean;
  56559. METALLIC_REFLECTANCEDIRECTUV: number;
  56560. ENVIRONMENTBRDF: boolean;
  56561. ENVIRONMENTBRDF_RGBD: boolean;
  56562. NORMAL: boolean;
  56563. TANGENT: boolean;
  56564. BUMP: boolean;
  56565. BUMPDIRECTUV: number;
  56566. OBJECTSPACE_NORMALMAP: boolean;
  56567. PARALLAX: boolean;
  56568. PARALLAXOCCLUSION: boolean;
  56569. NORMALXYSCALE: boolean;
  56570. LIGHTMAP: boolean;
  56571. LIGHTMAPDIRECTUV: number;
  56572. USELIGHTMAPASSHADOWMAP: boolean;
  56573. GAMMALIGHTMAP: boolean;
  56574. RGBDLIGHTMAP: boolean;
  56575. REFLECTION: boolean;
  56576. REFLECTIONMAP_3D: boolean;
  56577. REFLECTIONMAP_SPHERICAL: boolean;
  56578. REFLECTIONMAP_PLANAR: boolean;
  56579. REFLECTIONMAP_CUBIC: boolean;
  56580. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  56581. REFLECTIONMAP_PROJECTION: boolean;
  56582. REFLECTIONMAP_SKYBOX: boolean;
  56583. REFLECTIONMAP_EXPLICIT: boolean;
  56584. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  56585. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  56586. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  56587. INVERTCUBICMAP: boolean;
  56588. USESPHERICALFROMREFLECTIONMAP: boolean;
  56589. USEIRRADIANCEMAP: boolean;
  56590. SPHERICAL_HARMONICS: boolean;
  56591. USESPHERICALINVERTEX: boolean;
  56592. REFLECTIONMAP_OPPOSITEZ: boolean;
  56593. LODINREFLECTIONALPHA: boolean;
  56594. GAMMAREFLECTION: boolean;
  56595. RGBDREFLECTION: boolean;
  56596. LINEARSPECULARREFLECTION: boolean;
  56597. RADIANCEOCCLUSION: boolean;
  56598. HORIZONOCCLUSION: boolean;
  56599. INSTANCES: boolean;
  56600. THIN_INSTANCES: boolean;
  56601. PREPASS: boolean;
  56602. PREPASS_IRRADIANCE: boolean;
  56603. PREPASS_IRRADIANCE_INDEX: number;
  56604. PREPASS_ALBEDO: boolean;
  56605. PREPASS_ALBEDO_INDEX: number;
  56606. PREPASS_DEPTHNORMAL: boolean;
  56607. PREPASS_DEPTHNORMAL_INDEX: number;
  56608. SCENE_MRT_COUNT: number;
  56609. NUM_BONE_INFLUENCERS: number;
  56610. BonesPerMesh: number;
  56611. BONETEXTURE: boolean;
  56612. NONUNIFORMSCALING: boolean;
  56613. MORPHTARGETS: boolean;
  56614. MORPHTARGETS_NORMAL: boolean;
  56615. MORPHTARGETS_TANGENT: boolean;
  56616. MORPHTARGETS_UV: boolean;
  56617. NUM_MORPH_INFLUENCERS: number;
  56618. IMAGEPROCESSING: boolean;
  56619. VIGNETTE: boolean;
  56620. VIGNETTEBLENDMODEMULTIPLY: boolean;
  56621. VIGNETTEBLENDMODEOPAQUE: boolean;
  56622. TONEMAPPING: boolean;
  56623. TONEMAPPING_ACES: boolean;
  56624. CONTRAST: boolean;
  56625. COLORCURVES: boolean;
  56626. COLORGRADING: boolean;
  56627. COLORGRADING3D: boolean;
  56628. SAMPLER3DGREENDEPTH: boolean;
  56629. SAMPLER3DBGRMAP: boolean;
  56630. IMAGEPROCESSINGPOSTPROCESS: boolean;
  56631. EXPOSURE: boolean;
  56632. MULTIVIEW: boolean;
  56633. USEPHYSICALLIGHTFALLOFF: boolean;
  56634. USEGLTFLIGHTFALLOFF: boolean;
  56635. TWOSIDEDLIGHTING: boolean;
  56636. SHADOWFLOAT: boolean;
  56637. CLIPPLANE: boolean;
  56638. CLIPPLANE2: boolean;
  56639. CLIPPLANE3: boolean;
  56640. CLIPPLANE4: boolean;
  56641. CLIPPLANE5: boolean;
  56642. CLIPPLANE6: boolean;
  56643. POINTSIZE: boolean;
  56644. FOG: boolean;
  56645. LOGARITHMICDEPTH: boolean;
  56646. FORCENORMALFORWARD: boolean;
  56647. SPECULARAA: boolean;
  56648. CLEARCOAT: boolean;
  56649. CLEARCOAT_DEFAULTIOR: boolean;
  56650. CLEARCOAT_TEXTURE: boolean;
  56651. CLEARCOAT_TEXTUREDIRECTUV: number;
  56652. CLEARCOAT_BUMP: boolean;
  56653. CLEARCOAT_BUMPDIRECTUV: number;
  56654. CLEARCOAT_TINT: boolean;
  56655. CLEARCOAT_TINT_TEXTURE: boolean;
  56656. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  56657. ANISOTROPIC: boolean;
  56658. ANISOTROPIC_TEXTURE: boolean;
  56659. ANISOTROPIC_TEXTUREDIRECTUV: number;
  56660. BRDF_V_HEIGHT_CORRELATED: boolean;
  56661. MS_BRDF_ENERGY_CONSERVATION: boolean;
  56662. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  56663. SHEEN: boolean;
  56664. SHEEN_TEXTURE: boolean;
  56665. SHEEN_TEXTUREDIRECTUV: number;
  56666. SHEEN_LINKWITHALBEDO: boolean;
  56667. SHEEN_ROUGHNESS: boolean;
  56668. SHEEN_ALBEDOSCALING: boolean;
  56669. SUBSURFACE: boolean;
  56670. SS_REFRACTION: boolean;
  56671. SS_TRANSLUCENCY: boolean;
  56672. SS_SCATTERING: boolean;
  56673. SS_THICKNESSANDMASK_TEXTURE: boolean;
  56674. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  56675. SS_REFRACTIONMAP_3D: boolean;
  56676. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  56677. SS_LODINREFRACTIONALPHA: boolean;
  56678. SS_GAMMAREFRACTION: boolean;
  56679. SS_RGBDREFRACTION: boolean;
  56680. SS_LINEARSPECULARREFRACTION: boolean;
  56681. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  56682. SS_ALBEDOFORREFRACTIONTINT: boolean;
  56683. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  56684. UNLIT: boolean;
  56685. DEBUGMODE: number;
  56686. /**
  56687. * Initializes the PBR Material defines.
  56688. */
  56689. constructor();
  56690. /**
  56691. * Resets the PBR Material defines.
  56692. */
  56693. reset(): void;
  56694. }
  56695. /**
  56696. * The Physically based material base class of BJS.
  56697. *
  56698. * This offers the main features of a standard PBR material.
  56699. * For more information, please refer to the documentation :
  56700. * https://doc.babylonjs.com/how_to/physically_based_rendering
  56701. */
  56702. export abstract class PBRBaseMaterial extends PushMaterial {
  56703. /**
  56704. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  56705. */
  56706. static readonly PBRMATERIAL_OPAQUE: number;
  56707. /**
  56708. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  56709. */
  56710. static readonly PBRMATERIAL_ALPHATEST: number;
  56711. /**
  56712. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56713. */
  56714. static readonly PBRMATERIAL_ALPHABLEND: number;
  56715. /**
  56716. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56717. * They are also discarded below the alpha cutoff threshold to improve performances.
  56718. */
  56719. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  56720. /**
  56721. * Defines the default value of how much AO map is occluding the analytical lights
  56722. * (point spot...).
  56723. */
  56724. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  56725. /**
  56726. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  56727. */
  56728. static readonly LIGHTFALLOFF_PHYSICAL: number;
  56729. /**
  56730. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  56731. * to enhance interoperability with other engines.
  56732. */
  56733. static readonly LIGHTFALLOFF_GLTF: number;
  56734. /**
  56735. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  56736. * to enhance interoperability with other materials.
  56737. */
  56738. static readonly LIGHTFALLOFF_STANDARD: number;
  56739. /**
  56740. * Intensity of the direct lights e.g. the four lights available in your scene.
  56741. * This impacts both the direct diffuse and specular highlights.
  56742. */
  56743. protected _directIntensity: number;
  56744. /**
  56745. * Intensity of the emissive part of the material.
  56746. * This helps controlling the emissive effect without modifying the emissive color.
  56747. */
  56748. protected _emissiveIntensity: number;
  56749. /**
  56750. * Intensity of the environment e.g. how much the environment will light the object
  56751. * either through harmonics for rough material or through the refelction for shiny ones.
  56752. */
  56753. protected _environmentIntensity: number;
  56754. /**
  56755. * This is a special control allowing the reduction of the specular highlights coming from the
  56756. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  56757. */
  56758. protected _specularIntensity: number;
  56759. /**
  56760. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  56761. */
  56762. private _lightingInfos;
  56763. /**
  56764. * Debug Control allowing disabling the bump map on this material.
  56765. */
  56766. protected _disableBumpMap: boolean;
  56767. /**
  56768. * AKA Diffuse Texture in standard nomenclature.
  56769. */
  56770. protected _albedoTexture: Nullable<BaseTexture>;
  56771. /**
  56772. * AKA Occlusion Texture in other nomenclature.
  56773. */
  56774. protected _ambientTexture: Nullable<BaseTexture>;
  56775. /**
  56776. * AKA Occlusion Texture Intensity in other nomenclature.
  56777. */
  56778. protected _ambientTextureStrength: number;
  56779. /**
  56780. * Defines how much the AO map is occluding the analytical lights (point spot...).
  56781. * 1 means it completely occludes it
  56782. * 0 mean it has no impact
  56783. */
  56784. protected _ambientTextureImpactOnAnalyticalLights: number;
  56785. /**
  56786. * Stores the alpha values in a texture.
  56787. */
  56788. protected _opacityTexture: Nullable<BaseTexture>;
  56789. /**
  56790. * Stores the reflection values in a texture.
  56791. */
  56792. protected _reflectionTexture: Nullable<BaseTexture>;
  56793. /**
  56794. * Stores the emissive values in a texture.
  56795. */
  56796. protected _emissiveTexture: Nullable<BaseTexture>;
  56797. /**
  56798. * AKA Specular texture in other nomenclature.
  56799. */
  56800. protected _reflectivityTexture: Nullable<BaseTexture>;
  56801. /**
  56802. * Used to switch from specular/glossiness to metallic/roughness workflow.
  56803. */
  56804. protected _metallicTexture: Nullable<BaseTexture>;
  56805. /**
  56806. * Specifies the metallic scalar of the metallic/roughness workflow.
  56807. * Can also be used to scale the metalness values of the metallic texture.
  56808. */
  56809. protected _metallic: Nullable<number>;
  56810. /**
  56811. * Specifies the roughness scalar of the metallic/roughness workflow.
  56812. * Can also be used to scale the roughness values of the metallic texture.
  56813. */
  56814. protected _roughness: Nullable<number>;
  56815. /**
  56816. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  56817. * By default the indexOfrefraction is used to compute F0;
  56818. *
  56819. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  56820. *
  56821. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  56822. * F90 = metallicReflectanceColor;
  56823. */
  56824. protected _metallicF0Factor: number;
  56825. /**
  56826. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  56827. * By default the F90 is always 1;
  56828. *
  56829. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  56830. *
  56831. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  56832. * F90 = metallicReflectanceColor;
  56833. */
  56834. protected _metallicReflectanceColor: Color3;
  56835. /**
  56836. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  56837. * This is multiply against the scalar values defined in the material.
  56838. */
  56839. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  56840. /**
  56841. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  56842. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  56843. */
  56844. protected _microSurfaceTexture: Nullable<BaseTexture>;
  56845. /**
  56846. * Stores surface normal data used to displace a mesh in a texture.
  56847. */
  56848. protected _bumpTexture: Nullable<BaseTexture>;
  56849. /**
  56850. * Stores the pre-calculated light information of a mesh in a texture.
  56851. */
  56852. protected _lightmapTexture: Nullable<BaseTexture>;
  56853. /**
  56854. * The color of a material in ambient lighting.
  56855. */
  56856. protected _ambientColor: Color3;
  56857. /**
  56858. * AKA Diffuse Color in other nomenclature.
  56859. */
  56860. protected _albedoColor: Color3;
  56861. /**
  56862. * AKA Specular Color in other nomenclature.
  56863. */
  56864. protected _reflectivityColor: Color3;
  56865. /**
  56866. * The color applied when light is reflected from a material.
  56867. */
  56868. protected _reflectionColor: Color3;
  56869. /**
  56870. * The color applied when light is emitted from a material.
  56871. */
  56872. protected _emissiveColor: Color3;
  56873. /**
  56874. * AKA Glossiness in other nomenclature.
  56875. */
  56876. protected _microSurface: number;
  56877. /**
  56878. * Specifies that the material will use the light map as a show map.
  56879. */
  56880. protected _useLightmapAsShadowmap: boolean;
  56881. /**
  56882. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  56883. * makes the reflect vector face the model (under horizon).
  56884. */
  56885. protected _useHorizonOcclusion: boolean;
  56886. /**
  56887. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  56888. * too much the area relying on ambient texture to define their ambient occlusion.
  56889. */
  56890. protected _useRadianceOcclusion: boolean;
  56891. /**
  56892. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  56893. */
  56894. protected _useAlphaFromAlbedoTexture: boolean;
  56895. /**
  56896. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  56897. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  56898. */
  56899. protected _useSpecularOverAlpha: boolean;
  56900. /**
  56901. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  56902. */
  56903. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  56904. /**
  56905. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  56906. */
  56907. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  56908. /**
  56909. * Specifies if the metallic texture contains the roughness information in its green channel.
  56910. */
  56911. protected _useRoughnessFromMetallicTextureGreen: boolean;
  56912. /**
  56913. * Specifies if the metallic texture contains the metallness information in its blue channel.
  56914. */
  56915. protected _useMetallnessFromMetallicTextureBlue: boolean;
  56916. /**
  56917. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  56918. */
  56919. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  56920. /**
  56921. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  56922. */
  56923. protected _useAmbientInGrayScale: boolean;
  56924. /**
  56925. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  56926. * The material will try to infer what glossiness each pixel should be.
  56927. */
  56928. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  56929. /**
  56930. * Defines the falloff type used in this material.
  56931. * It by default is Physical.
  56932. */
  56933. protected _lightFalloff: number;
  56934. /**
  56935. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  56936. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  56937. */
  56938. protected _useRadianceOverAlpha: boolean;
  56939. /**
  56940. * Allows using an object space normal map (instead of tangent space).
  56941. */
  56942. protected _useObjectSpaceNormalMap: boolean;
  56943. /**
  56944. * Allows using the bump map in parallax mode.
  56945. */
  56946. protected _useParallax: boolean;
  56947. /**
  56948. * Allows using the bump map in parallax occlusion mode.
  56949. */
  56950. protected _useParallaxOcclusion: boolean;
  56951. /**
  56952. * Controls the scale bias of the parallax mode.
  56953. */
  56954. protected _parallaxScaleBias: number;
  56955. /**
  56956. * If sets to true, disables all the lights affecting the material.
  56957. */
  56958. protected _disableLighting: boolean;
  56959. /**
  56960. * Number of Simultaneous lights allowed on the material.
  56961. */
  56962. protected _maxSimultaneousLights: number;
  56963. /**
  56964. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  56965. */
  56966. protected _invertNormalMapX: boolean;
  56967. /**
  56968. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  56969. */
  56970. protected _invertNormalMapY: boolean;
  56971. /**
  56972. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56973. */
  56974. protected _twoSidedLighting: boolean;
  56975. /**
  56976. * Defines the alpha limits in alpha test mode.
  56977. */
  56978. protected _alphaCutOff: number;
  56979. /**
  56980. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  56981. */
  56982. protected _forceAlphaTest: boolean;
  56983. /**
  56984. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56985. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  56986. */
  56987. protected _useAlphaFresnel: boolean;
  56988. /**
  56989. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56990. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  56991. */
  56992. protected _useLinearAlphaFresnel: boolean;
  56993. /**
  56994. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  56995. * from cos thetav and roughness:
  56996. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  56997. */
  56998. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  56999. /**
  57000. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  57001. */
  57002. protected _forceIrradianceInFragment: boolean;
  57003. private _realTimeFiltering;
  57004. /**
  57005. * Enables realtime filtering on the texture.
  57006. */
  57007. get realTimeFiltering(): boolean;
  57008. set realTimeFiltering(b: boolean);
  57009. private _realTimeFilteringQuality;
  57010. /**
  57011. * Quality switch for realtime filtering
  57012. */
  57013. get realTimeFilteringQuality(): number;
  57014. set realTimeFilteringQuality(n: number);
  57015. /**
  57016. * Can this material render to several textures at once
  57017. */
  57018. get canRenderToMRT(): boolean;
  57019. /**
  57020. * Force normal to face away from face.
  57021. */
  57022. protected _forceNormalForward: boolean;
  57023. /**
  57024. * Enables specular anti aliasing in the PBR shader.
  57025. * It will both interacts on the Geometry for analytical and IBL lighting.
  57026. * It also prefilter the roughness map based on the bump values.
  57027. */
  57028. protected _enableSpecularAntiAliasing: boolean;
  57029. /**
  57030. * Default configuration related to image processing available in the PBR Material.
  57031. */
  57032. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57033. /**
  57034. * Keep track of the image processing observer to allow dispose and replace.
  57035. */
  57036. private _imageProcessingObserver;
  57037. /**
  57038. * Attaches a new image processing configuration to the PBR Material.
  57039. * @param configuration
  57040. */
  57041. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57042. /**
  57043. * Stores the available render targets.
  57044. */
  57045. private _renderTargets;
  57046. /**
  57047. * Sets the global ambient color for the material used in lighting calculations.
  57048. */
  57049. private _globalAmbientColor;
  57050. /**
  57051. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  57052. */
  57053. private _useLogarithmicDepth;
  57054. /**
  57055. * If set to true, no lighting calculations will be applied.
  57056. */
  57057. private _unlit;
  57058. private _debugMode;
  57059. /**
  57060. * @hidden
  57061. * This is reserved for the inspector.
  57062. * Defines the material debug mode.
  57063. * It helps seeing only some components of the material while troubleshooting.
  57064. */
  57065. debugMode: number;
  57066. /**
  57067. * @hidden
  57068. * This is reserved for the inspector.
  57069. * Specify from where on screen the debug mode should start.
  57070. * The value goes from -1 (full screen) to 1 (not visible)
  57071. * It helps with side by side comparison against the final render
  57072. * This defaults to -1
  57073. */
  57074. private debugLimit;
  57075. /**
  57076. * @hidden
  57077. * This is reserved for the inspector.
  57078. * As the default viewing range might not be enough (if the ambient is really small for instance)
  57079. * You can use the factor to better multiply the final value.
  57080. */
  57081. private debugFactor;
  57082. /**
  57083. * Defines the clear coat layer parameters for the material.
  57084. */
  57085. readonly clearCoat: PBRClearCoatConfiguration;
  57086. /**
  57087. * Defines the anisotropic parameters for the material.
  57088. */
  57089. readonly anisotropy: PBRAnisotropicConfiguration;
  57090. /**
  57091. * Defines the BRDF parameters for the material.
  57092. */
  57093. readonly brdf: PBRBRDFConfiguration;
  57094. /**
  57095. * Defines the Sheen parameters for the material.
  57096. */
  57097. readonly sheen: PBRSheenConfiguration;
  57098. /**
  57099. * Defines the SubSurface parameters for the material.
  57100. */
  57101. readonly subSurface: PBRSubSurfaceConfiguration;
  57102. /**
  57103. * Defines the detail map parameters for the material.
  57104. */
  57105. readonly detailMap: DetailMapConfiguration;
  57106. protected _rebuildInParallel: boolean;
  57107. /**
  57108. * Instantiates a new PBRMaterial instance.
  57109. *
  57110. * @param name The material name
  57111. * @param scene The scene the material will be use in.
  57112. */
  57113. constructor(name: string, scene: Scene);
  57114. /**
  57115. * Gets a boolean indicating that current material needs to register RTT
  57116. */
  57117. get hasRenderTargetTextures(): boolean;
  57118. /**
  57119. * Gets the name of the material class.
  57120. */
  57121. getClassName(): string;
  57122. /**
  57123. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  57124. */
  57125. get useLogarithmicDepth(): boolean;
  57126. /**
  57127. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  57128. */
  57129. set useLogarithmicDepth(value: boolean);
  57130. /**
  57131. * Returns true if alpha blending should be disabled.
  57132. */
  57133. protected get _disableAlphaBlending(): boolean;
  57134. /**
  57135. * Specifies whether or not this material should be rendered in alpha blend mode.
  57136. */
  57137. needAlphaBlending(): boolean;
  57138. /**
  57139. * Specifies whether or not this material should be rendered in alpha test mode.
  57140. */
  57141. needAlphaTesting(): boolean;
  57142. /**
  57143. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  57144. */
  57145. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  57146. /**
  57147. * Gets the texture used for the alpha test.
  57148. */
  57149. getAlphaTestTexture(): Nullable<BaseTexture>;
  57150. /**
  57151. * Specifies that the submesh is ready to be used.
  57152. * @param mesh - BJS mesh.
  57153. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  57154. * @param useInstances - Specifies that instances should be used.
  57155. * @returns - boolean indicating that the submesh is ready or not.
  57156. */
  57157. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57158. /**
  57159. * Specifies if the material uses metallic roughness workflow.
  57160. * @returns boolean specifiying if the material uses metallic roughness workflow.
  57161. */
  57162. isMetallicWorkflow(): boolean;
  57163. private _prepareEffect;
  57164. private _prepareDefines;
  57165. /**
  57166. * Force shader compilation
  57167. */
  57168. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  57169. /**
  57170. * Initializes the uniform buffer layout for the shader.
  57171. */
  57172. buildUniformLayout(): void;
  57173. /**
  57174. * Unbinds the material from the mesh
  57175. */
  57176. unbind(): void;
  57177. /**
  57178. * Binds the submesh data.
  57179. * @param world - The world matrix.
  57180. * @param mesh - The BJS mesh.
  57181. * @param subMesh - A submesh of the BJS mesh.
  57182. */
  57183. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57184. /**
  57185. * Returns the animatable textures.
  57186. * @returns - Array of animatable textures.
  57187. */
  57188. getAnimatables(): IAnimatable[];
  57189. /**
  57190. * Returns the texture used for reflections.
  57191. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  57192. */
  57193. private _getReflectionTexture;
  57194. /**
  57195. * Returns an array of the actively used textures.
  57196. * @returns - Array of BaseTextures
  57197. */
  57198. getActiveTextures(): BaseTexture[];
  57199. /**
  57200. * Checks to see if a texture is used in the material.
  57201. * @param texture - Base texture to use.
  57202. * @returns - Boolean specifying if a texture is used in the material.
  57203. */
  57204. hasTexture(texture: BaseTexture): boolean;
  57205. /**
  57206. * Sets the required values to the prepass renderer.
  57207. * @param prePassRenderer defines the prepass renderer to setup
  57208. */
  57209. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  57210. /**
  57211. * Disposes the resources of the material.
  57212. * @param forceDisposeEffect - Forces the disposal of effects.
  57213. * @param forceDisposeTextures - Forces the disposal of all textures.
  57214. */
  57215. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  57216. }
  57217. }
  57218. declare module BABYLON {
  57219. /**
  57220. * The Physically based material of BJS.
  57221. *
  57222. * This offers the main features of a standard PBR material.
  57223. * For more information, please refer to the documentation :
  57224. * https://doc.babylonjs.com/how_to/physically_based_rendering
  57225. */
  57226. export class PBRMaterial extends PBRBaseMaterial {
  57227. /**
  57228. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  57229. */
  57230. static readonly PBRMATERIAL_OPAQUE: number;
  57231. /**
  57232. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  57233. */
  57234. static readonly PBRMATERIAL_ALPHATEST: number;
  57235. /**
  57236. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57237. */
  57238. static readonly PBRMATERIAL_ALPHABLEND: number;
  57239. /**
  57240. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57241. * They are also discarded below the alpha cutoff threshold to improve performances.
  57242. */
  57243. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  57244. /**
  57245. * Defines the default value of how much AO map is occluding the analytical lights
  57246. * (point spot...).
  57247. */
  57248. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  57249. /**
  57250. * Intensity of the direct lights e.g. the four lights available in your scene.
  57251. * This impacts both the direct diffuse and specular highlights.
  57252. */
  57253. directIntensity: number;
  57254. /**
  57255. * Intensity of the emissive part of the material.
  57256. * This helps controlling the emissive effect without modifying the emissive color.
  57257. */
  57258. emissiveIntensity: number;
  57259. /**
  57260. * Intensity of the environment e.g. how much the environment will light the object
  57261. * either through harmonics for rough material or through the refelction for shiny ones.
  57262. */
  57263. environmentIntensity: number;
  57264. /**
  57265. * This is a special control allowing the reduction of the specular highlights coming from the
  57266. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  57267. */
  57268. specularIntensity: number;
  57269. /**
  57270. * Debug Control allowing disabling the bump map on this material.
  57271. */
  57272. disableBumpMap: boolean;
  57273. /**
  57274. * AKA Diffuse Texture in standard nomenclature.
  57275. */
  57276. albedoTexture: BaseTexture;
  57277. /**
  57278. * AKA Occlusion Texture in other nomenclature.
  57279. */
  57280. ambientTexture: BaseTexture;
  57281. /**
  57282. * AKA Occlusion Texture Intensity in other nomenclature.
  57283. */
  57284. ambientTextureStrength: number;
  57285. /**
  57286. * Defines how much the AO map is occluding the analytical lights (point spot...).
  57287. * 1 means it completely occludes it
  57288. * 0 mean it has no impact
  57289. */
  57290. ambientTextureImpactOnAnalyticalLights: number;
  57291. /**
  57292. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  57293. */
  57294. opacityTexture: BaseTexture;
  57295. /**
  57296. * Stores the reflection values in a texture.
  57297. */
  57298. reflectionTexture: Nullable<BaseTexture>;
  57299. /**
  57300. * Stores the emissive values in a texture.
  57301. */
  57302. emissiveTexture: BaseTexture;
  57303. /**
  57304. * AKA Specular texture in other nomenclature.
  57305. */
  57306. reflectivityTexture: BaseTexture;
  57307. /**
  57308. * Used to switch from specular/glossiness to metallic/roughness workflow.
  57309. */
  57310. metallicTexture: BaseTexture;
  57311. /**
  57312. * Specifies the metallic scalar of the metallic/roughness workflow.
  57313. * Can also be used to scale the metalness values of the metallic texture.
  57314. */
  57315. metallic: Nullable<number>;
  57316. /**
  57317. * Specifies the roughness scalar of the metallic/roughness workflow.
  57318. * Can also be used to scale the roughness values of the metallic texture.
  57319. */
  57320. roughness: Nullable<number>;
  57321. /**
  57322. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  57323. * By default the indexOfrefraction is used to compute F0;
  57324. *
  57325. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  57326. *
  57327. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  57328. * F90 = metallicReflectanceColor;
  57329. */
  57330. metallicF0Factor: number;
  57331. /**
  57332. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  57333. * By default the F90 is always 1;
  57334. *
  57335. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  57336. *
  57337. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  57338. * F90 = metallicReflectanceColor;
  57339. */
  57340. metallicReflectanceColor: Color3;
  57341. /**
  57342. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  57343. * This is multiply against the scalar values defined in the material.
  57344. */
  57345. metallicReflectanceTexture: Nullable<BaseTexture>;
  57346. /**
  57347. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  57348. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  57349. */
  57350. microSurfaceTexture: BaseTexture;
  57351. /**
  57352. * Stores surface normal data used to displace a mesh in a texture.
  57353. */
  57354. bumpTexture: BaseTexture;
  57355. /**
  57356. * Stores the pre-calculated light information of a mesh in a texture.
  57357. */
  57358. lightmapTexture: BaseTexture;
  57359. /**
  57360. * Stores the refracted light information in a texture.
  57361. */
  57362. get refractionTexture(): Nullable<BaseTexture>;
  57363. set refractionTexture(value: Nullable<BaseTexture>);
  57364. /**
  57365. * The color of a material in ambient lighting.
  57366. */
  57367. ambientColor: Color3;
  57368. /**
  57369. * AKA Diffuse Color in other nomenclature.
  57370. */
  57371. albedoColor: Color3;
  57372. /**
  57373. * AKA Specular Color in other nomenclature.
  57374. */
  57375. reflectivityColor: Color3;
  57376. /**
  57377. * The color reflected from the material.
  57378. */
  57379. reflectionColor: Color3;
  57380. /**
  57381. * The color emitted from the material.
  57382. */
  57383. emissiveColor: Color3;
  57384. /**
  57385. * AKA Glossiness in other nomenclature.
  57386. */
  57387. microSurface: number;
  57388. /**
  57389. * Index of refraction of the material base layer.
  57390. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  57391. *
  57392. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  57393. *
  57394. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  57395. */
  57396. get indexOfRefraction(): number;
  57397. set indexOfRefraction(value: number);
  57398. /**
  57399. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  57400. */
  57401. get invertRefractionY(): boolean;
  57402. set invertRefractionY(value: boolean);
  57403. /**
  57404. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  57405. * Materials half opaque for instance using refraction could benefit from this control.
  57406. */
  57407. get linkRefractionWithTransparency(): boolean;
  57408. set linkRefractionWithTransparency(value: boolean);
  57409. /**
  57410. * If true, the light map contains occlusion information instead of lighting info.
  57411. */
  57412. useLightmapAsShadowmap: boolean;
  57413. /**
  57414. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  57415. */
  57416. useAlphaFromAlbedoTexture: boolean;
  57417. /**
  57418. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  57419. */
  57420. forceAlphaTest: boolean;
  57421. /**
  57422. * Defines the alpha limits in alpha test mode.
  57423. */
  57424. alphaCutOff: number;
  57425. /**
  57426. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  57427. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  57428. */
  57429. useSpecularOverAlpha: boolean;
  57430. /**
  57431. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  57432. */
  57433. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  57434. /**
  57435. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  57436. */
  57437. useRoughnessFromMetallicTextureAlpha: boolean;
  57438. /**
  57439. * Specifies if the metallic texture contains the roughness information in its green channel.
  57440. */
  57441. useRoughnessFromMetallicTextureGreen: boolean;
  57442. /**
  57443. * Specifies if the metallic texture contains the metallness information in its blue channel.
  57444. */
  57445. useMetallnessFromMetallicTextureBlue: boolean;
  57446. /**
  57447. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  57448. */
  57449. useAmbientOcclusionFromMetallicTextureRed: boolean;
  57450. /**
  57451. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  57452. */
  57453. useAmbientInGrayScale: boolean;
  57454. /**
  57455. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  57456. * The material will try to infer what glossiness each pixel should be.
  57457. */
  57458. useAutoMicroSurfaceFromReflectivityMap: boolean;
  57459. /**
  57460. * BJS is using an harcoded light falloff based on a manually sets up range.
  57461. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  57462. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  57463. */
  57464. get usePhysicalLightFalloff(): boolean;
  57465. /**
  57466. * BJS is using an harcoded light falloff based on a manually sets up range.
  57467. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  57468. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  57469. */
  57470. set usePhysicalLightFalloff(value: boolean);
  57471. /**
  57472. * In order to support the falloff compatibility with gltf, a special mode has been added
  57473. * to reproduce the gltf light falloff.
  57474. */
  57475. get useGLTFLightFalloff(): boolean;
  57476. /**
  57477. * In order to support the falloff compatibility with gltf, a special mode has been added
  57478. * to reproduce the gltf light falloff.
  57479. */
  57480. set useGLTFLightFalloff(value: boolean);
  57481. /**
  57482. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  57483. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  57484. */
  57485. useRadianceOverAlpha: boolean;
  57486. /**
  57487. * Allows using an object space normal map (instead of tangent space).
  57488. */
  57489. useObjectSpaceNormalMap: boolean;
  57490. /**
  57491. * Allows using the bump map in parallax mode.
  57492. */
  57493. useParallax: boolean;
  57494. /**
  57495. * Allows using the bump map in parallax occlusion mode.
  57496. */
  57497. useParallaxOcclusion: boolean;
  57498. /**
  57499. * Controls the scale bias of the parallax mode.
  57500. */
  57501. parallaxScaleBias: number;
  57502. /**
  57503. * If sets to true, disables all the lights affecting the material.
  57504. */
  57505. disableLighting: boolean;
  57506. /**
  57507. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  57508. */
  57509. forceIrradianceInFragment: boolean;
  57510. /**
  57511. * Number of Simultaneous lights allowed on the material.
  57512. */
  57513. maxSimultaneousLights: number;
  57514. /**
  57515. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  57516. */
  57517. invertNormalMapX: boolean;
  57518. /**
  57519. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  57520. */
  57521. invertNormalMapY: boolean;
  57522. /**
  57523. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  57524. */
  57525. twoSidedLighting: boolean;
  57526. /**
  57527. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57528. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  57529. */
  57530. useAlphaFresnel: boolean;
  57531. /**
  57532. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57533. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  57534. */
  57535. useLinearAlphaFresnel: boolean;
  57536. /**
  57537. * Let user defines the brdf lookup texture used for IBL.
  57538. * A default 8bit version is embedded but you could point at :
  57539. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  57540. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  57541. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  57542. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  57543. */
  57544. environmentBRDFTexture: Nullable<BaseTexture>;
  57545. /**
  57546. * Force normal to face away from face.
  57547. */
  57548. forceNormalForward: boolean;
  57549. /**
  57550. * Enables specular anti aliasing in the PBR shader.
  57551. * It will both interacts on the Geometry for analytical and IBL lighting.
  57552. * It also prefilter the roughness map based on the bump values.
  57553. */
  57554. enableSpecularAntiAliasing: boolean;
  57555. /**
  57556. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  57557. * makes the reflect vector face the model (under horizon).
  57558. */
  57559. useHorizonOcclusion: boolean;
  57560. /**
  57561. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  57562. * too much the area relying on ambient texture to define their ambient occlusion.
  57563. */
  57564. useRadianceOcclusion: boolean;
  57565. /**
  57566. * If set to true, no lighting calculations will be applied.
  57567. */
  57568. unlit: boolean;
  57569. /**
  57570. * Gets the image processing configuration used either in this material.
  57571. */
  57572. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57573. /**
  57574. * Sets the Default image processing configuration used either in the this material.
  57575. *
  57576. * If sets to null, the scene one is in use.
  57577. */
  57578. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57579. /**
  57580. * Gets wether the color curves effect is enabled.
  57581. */
  57582. get cameraColorCurvesEnabled(): boolean;
  57583. /**
  57584. * Sets wether the color curves effect is enabled.
  57585. */
  57586. set cameraColorCurvesEnabled(value: boolean);
  57587. /**
  57588. * Gets wether the color grading effect is enabled.
  57589. */
  57590. get cameraColorGradingEnabled(): boolean;
  57591. /**
  57592. * Gets wether the color grading effect is enabled.
  57593. */
  57594. set cameraColorGradingEnabled(value: boolean);
  57595. /**
  57596. * Gets wether tonemapping is enabled or not.
  57597. */
  57598. get cameraToneMappingEnabled(): boolean;
  57599. /**
  57600. * Sets wether tonemapping is enabled or not
  57601. */
  57602. set cameraToneMappingEnabled(value: boolean);
  57603. /**
  57604. * The camera exposure used on this material.
  57605. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57606. * This corresponds to a photographic exposure.
  57607. */
  57608. get cameraExposure(): number;
  57609. /**
  57610. * The camera exposure used on this material.
  57611. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57612. * This corresponds to a photographic exposure.
  57613. */
  57614. set cameraExposure(value: number);
  57615. /**
  57616. * Gets The camera contrast used on this material.
  57617. */
  57618. get cameraContrast(): number;
  57619. /**
  57620. * Sets The camera contrast used on this material.
  57621. */
  57622. set cameraContrast(value: number);
  57623. /**
  57624. * Gets the Color Grading 2D Lookup Texture.
  57625. */
  57626. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  57627. /**
  57628. * Sets the Color Grading 2D Lookup Texture.
  57629. */
  57630. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  57631. /**
  57632. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57633. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57634. * 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;
  57635. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57636. */
  57637. get cameraColorCurves(): Nullable<ColorCurves>;
  57638. /**
  57639. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57640. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57641. * 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;
  57642. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57643. */
  57644. set cameraColorCurves(value: Nullable<ColorCurves>);
  57645. /**
  57646. * Instantiates a new PBRMaterial instance.
  57647. *
  57648. * @param name The material name
  57649. * @param scene The scene the material will be use in.
  57650. */
  57651. constructor(name: string, scene: Scene);
  57652. /**
  57653. * Returns the name of this material class.
  57654. */
  57655. getClassName(): string;
  57656. /**
  57657. * Makes a duplicate of the current material.
  57658. * @param name - name to use for the new material.
  57659. */
  57660. clone(name: string): PBRMaterial;
  57661. /**
  57662. * Serializes this PBR Material.
  57663. * @returns - An object with the serialized material.
  57664. */
  57665. serialize(): any;
  57666. /**
  57667. * Parses a PBR Material from a serialized object.
  57668. * @param source - Serialized object.
  57669. * @param scene - BJS scene instance.
  57670. * @param rootUrl - url for the scene object
  57671. * @returns - PBRMaterial
  57672. */
  57673. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  57674. }
  57675. }
  57676. declare module BABYLON {
  57677. /**
  57678. * Direct draw surface info
  57679. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  57680. */
  57681. export interface DDSInfo {
  57682. /**
  57683. * Width of the texture
  57684. */
  57685. width: number;
  57686. /**
  57687. * Width of the texture
  57688. */
  57689. height: number;
  57690. /**
  57691. * Number of Mipmaps for the texture
  57692. * @see https://en.wikipedia.org/wiki/Mipmap
  57693. */
  57694. mipmapCount: number;
  57695. /**
  57696. * If the textures format is a known fourCC format
  57697. * @see https://www.fourcc.org/
  57698. */
  57699. isFourCC: boolean;
  57700. /**
  57701. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  57702. */
  57703. isRGB: boolean;
  57704. /**
  57705. * If the texture is a lumincance format
  57706. */
  57707. isLuminance: boolean;
  57708. /**
  57709. * If this is a cube texture
  57710. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  57711. */
  57712. isCube: boolean;
  57713. /**
  57714. * If the texture is a compressed format eg. FOURCC_DXT1
  57715. */
  57716. isCompressed: boolean;
  57717. /**
  57718. * The dxgiFormat of the texture
  57719. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  57720. */
  57721. dxgiFormat: number;
  57722. /**
  57723. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  57724. */
  57725. textureType: number;
  57726. /**
  57727. * Sphericle polynomial created for the dds texture
  57728. */
  57729. sphericalPolynomial?: SphericalPolynomial;
  57730. }
  57731. /**
  57732. * Class used to provide DDS decompression tools
  57733. */
  57734. export class DDSTools {
  57735. /**
  57736. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  57737. */
  57738. static StoreLODInAlphaChannel: boolean;
  57739. /**
  57740. * Gets DDS information from an array buffer
  57741. * @param data defines the array buffer view to read data from
  57742. * @returns the DDS information
  57743. */
  57744. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  57745. private static _FloatView;
  57746. private static _Int32View;
  57747. private static _ToHalfFloat;
  57748. private static _FromHalfFloat;
  57749. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  57750. private static _GetHalfFloatRGBAArrayBuffer;
  57751. private static _GetFloatRGBAArrayBuffer;
  57752. private static _GetFloatAsUIntRGBAArrayBuffer;
  57753. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  57754. private static _GetRGBAArrayBuffer;
  57755. private static _ExtractLongWordOrder;
  57756. private static _GetRGBArrayBuffer;
  57757. private static _GetLuminanceArrayBuffer;
  57758. /**
  57759. * Uploads DDS Levels to a Babylon Texture
  57760. * @hidden
  57761. */
  57762. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  57763. }
  57764. interface ThinEngine {
  57765. /**
  57766. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  57767. * @param rootUrl defines the url where the file to load is located
  57768. * @param scene defines the current scene
  57769. * @param lodScale defines scale to apply to the mip map selection
  57770. * @param lodOffset defines offset to apply to the mip map selection
  57771. * @param onLoad defines an optional callback raised when the texture is loaded
  57772. * @param onError defines an optional callback raised if there is an issue to load the texture
  57773. * @param format defines the format of the data
  57774. * @param forcedExtension defines the extension to use to pick the right loader
  57775. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  57776. * @returns the cube texture as an InternalTexture
  57777. */
  57778. 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;
  57779. }
  57780. }
  57781. declare module BABYLON {
  57782. /**
  57783. * Implementation of the DDS Texture Loader.
  57784. * @hidden
  57785. */
  57786. export class _DDSTextureLoader implements IInternalTextureLoader {
  57787. /**
  57788. * Defines wether the loader supports cascade loading the different faces.
  57789. */
  57790. readonly supportCascades: boolean;
  57791. /**
  57792. * This returns if the loader support the current file information.
  57793. * @param extension defines the file extension of the file being loaded
  57794. * @returns true if the loader can load the specified file
  57795. */
  57796. canLoad(extension: string): boolean;
  57797. /**
  57798. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57799. * @param data contains the texture data
  57800. * @param texture defines the BabylonJS internal texture
  57801. * @param createPolynomials will be true if polynomials have been requested
  57802. * @param onLoad defines the callback to trigger once the texture is ready
  57803. * @param onError defines the callback to trigger in case of error
  57804. */
  57805. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57806. /**
  57807. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57808. * @param data contains the texture data
  57809. * @param texture defines the BabylonJS internal texture
  57810. * @param callback defines the method to call once ready to upload
  57811. */
  57812. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57813. }
  57814. }
  57815. declare module BABYLON {
  57816. /**
  57817. * Implementation of the ENV Texture Loader.
  57818. * @hidden
  57819. */
  57820. export class _ENVTextureLoader implements IInternalTextureLoader {
  57821. /**
  57822. * Defines wether the loader supports cascade loading the different faces.
  57823. */
  57824. readonly supportCascades: boolean;
  57825. /**
  57826. * This returns if the loader support the current file information.
  57827. * @param extension defines the file extension of the file being loaded
  57828. * @returns true if the loader can load the specified file
  57829. */
  57830. canLoad(extension: string): boolean;
  57831. /**
  57832. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57833. * @param data contains the texture data
  57834. * @param texture defines the BabylonJS internal texture
  57835. * @param createPolynomials will be true if polynomials have been requested
  57836. * @param onLoad defines the callback to trigger once the texture is ready
  57837. * @param onError defines the callback to trigger in case of error
  57838. */
  57839. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57840. /**
  57841. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57842. * @param data contains the texture data
  57843. * @param texture defines the BabylonJS internal texture
  57844. * @param callback defines the method to call once ready to upload
  57845. */
  57846. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57847. }
  57848. }
  57849. declare module BABYLON {
  57850. /**
  57851. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  57852. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  57853. */
  57854. export class KhronosTextureContainer {
  57855. /** contents of the KTX container file */
  57856. data: ArrayBufferView;
  57857. private static HEADER_LEN;
  57858. private static COMPRESSED_2D;
  57859. private static COMPRESSED_3D;
  57860. private static TEX_2D;
  57861. private static TEX_3D;
  57862. /**
  57863. * Gets the openGL type
  57864. */
  57865. glType: number;
  57866. /**
  57867. * Gets the openGL type size
  57868. */
  57869. glTypeSize: number;
  57870. /**
  57871. * Gets the openGL format
  57872. */
  57873. glFormat: number;
  57874. /**
  57875. * Gets the openGL internal format
  57876. */
  57877. glInternalFormat: number;
  57878. /**
  57879. * Gets the base internal format
  57880. */
  57881. glBaseInternalFormat: number;
  57882. /**
  57883. * Gets image width in pixel
  57884. */
  57885. pixelWidth: number;
  57886. /**
  57887. * Gets image height in pixel
  57888. */
  57889. pixelHeight: number;
  57890. /**
  57891. * Gets image depth in pixels
  57892. */
  57893. pixelDepth: number;
  57894. /**
  57895. * Gets the number of array elements
  57896. */
  57897. numberOfArrayElements: number;
  57898. /**
  57899. * Gets the number of faces
  57900. */
  57901. numberOfFaces: number;
  57902. /**
  57903. * Gets the number of mipmap levels
  57904. */
  57905. numberOfMipmapLevels: number;
  57906. /**
  57907. * Gets the bytes of key value data
  57908. */
  57909. bytesOfKeyValueData: number;
  57910. /**
  57911. * Gets the load type
  57912. */
  57913. loadType: number;
  57914. /**
  57915. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  57916. */
  57917. isInvalid: boolean;
  57918. /**
  57919. * Creates a new KhronosTextureContainer
  57920. * @param data contents of the KTX container file
  57921. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  57922. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  57923. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  57924. */
  57925. constructor(
  57926. /** contents of the KTX container file */
  57927. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  57928. /**
  57929. * Uploads KTX content to a Babylon Texture.
  57930. * It is assumed that the texture has already been created & is currently bound
  57931. * @hidden
  57932. */
  57933. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  57934. private _upload2DCompressedLevels;
  57935. /**
  57936. * Checks if the given data starts with a KTX file identifier.
  57937. * @param data the data to check
  57938. * @returns true if the data is a KTX file or false otherwise
  57939. */
  57940. static IsValid(data: ArrayBufferView): boolean;
  57941. }
  57942. }
  57943. declare module BABYLON {
  57944. /**
  57945. * Helper class to push actions to a pool of workers.
  57946. */
  57947. export class WorkerPool implements IDisposable {
  57948. private _workerInfos;
  57949. private _pendingActions;
  57950. /**
  57951. * Constructor
  57952. * @param workers Array of workers to use for actions
  57953. */
  57954. constructor(workers: Array<Worker>);
  57955. /**
  57956. * Terminates all workers and clears any pending actions.
  57957. */
  57958. dispose(): void;
  57959. /**
  57960. * Pushes an action to the worker pool. If all the workers are active, the action will be
  57961. * pended until a worker has completed its action.
  57962. * @param action The action to perform. Call onComplete when the action is complete.
  57963. */
  57964. push(action: (worker: Worker, onComplete: () => void) => void): void;
  57965. private _execute;
  57966. }
  57967. }
  57968. declare module BABYLON {
  57969. /**
  57970. * Class for loading KTX2 files
  57971. * @hidden
  57972. */
  57973. export class KhronosTextureContainer2 {
  57974. private static _WorkerPoolPromise?;
  57975. private static _Initialized;
  57976. private static _Ktx2Decoder;
  57977. /**
  57978. * URL to use when loading the KTX2 decoder module
  57979. */
  57980. static JSModuleURL: string;
  57981. /**
  57982. * Default number of workers used to handle data decoding
  57983. */
  57984. static DefaultNumWorkers: number;
  57985. private static GetDefaultNumWorkers;
  57986. private _engine;
  57987. private static _CreateWorkerPool;
  57988. /**
  57989. * Constructor
  57990. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  57991. */
  57992. constructor(engine: ThinEngine, numWorkers?: number);
  57993. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  57994. /**
  57995. * Stop all async operations and release resources.
  57996. */
  57997. dispose(): void;
  57998. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  57999. /**
  58000. * Checks if the given data starts with a KTX2 file identifier.
  58001. * @param data the data to check
  58002. * @returns true if the data is a KTX2 file or false otherwise
  58003. */
  58004. static IsValid(data: ArrayBufferView): boolean;
  58005. }
  58006. export function workerFunc(): void;
  58007. }
  58008. declare module BABYLON {
  58009. /**
  58010. * Implementation of the KTX Texture Loader.
  58011. * @hidden
  58012. */
  58013. export class _KTXTextureLoader implements IInternalTextureLoader {
  58014. /**
  58015. * Defines wether the loader supports cascade loading the different faces.
  58016. */
  58017. readonly supportCascades: boolean;
  58018. /**
  58019. * This returns if the loader support the current file information.
  58020. * @param extension defines the file extension of the file being loaded
  58021. * @param mimeType defines the optional mime type of the file being loaded
  58022. * @returns true if the loader can load the specified file
  58023. */
  58024. canLoad(extension: string, mimeType?: string): boolean;
  58025. /**
  58026. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58027. * @param data contains the texture data
  58028. * @param texture defines the BabylonJS internal texture
  58029. * @param createPolynomials will be true if polynomials have been requested
  58030. * @param onLoad defines the callback to trigger once the texture is ready
  58031. * @param onError defines the callback to trigger in case of error
  58032. */
  58033. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58034. /**
  58035. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58036. * @param data contains the texture data
  58037. * @param texture defines the BabylonJS internal texture
  58038. * @param callback defines the method to call once ready to upload
  58039. */
  58040. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  58041. }
  58042. }
  58043. declare module BABYLON {
  58044. /** @hidden */
  58045. export var _forceSceneHelpersToBundle: boolean;
  58046. interface Scene {
  58047. /**
  58048. * Creates a default light for the scene.
  58049. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  58050. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  58051. */
  58052. createDefaultLight(replace?: boolean): void;
  58053. /**
  58054. * Creates a default camera for the scene.
  58055. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  58056. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58057. * @param replace has default false, when true replaces the active camera in the scene
  58058. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  58059. */
  58060. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58061. /**
  58062. * Creates a default camera and a default light.
  58063. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  58064. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58065. * @param replace has the default false, when true replaces the active camera/light in the scene
  58066. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  58067. */
  58068. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58069. /**
  58070. * Creates a new sky box
  58071. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  58072. * @param environmentTexture defines the texture to use as environment texture
  58073. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  58074. * @param scale defines the overall scale of the skybox
  58075. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  58076. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  58077. * @returns a new mesh holding the sky box
  58078. */
  58079. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  58080. /**
  58081. * Creates a new environment
  58082. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  58083. * @param options defines the options you can use to configure the environment
  58084. * @returns the new EnvironmentHelper
  58085. */
  58086. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  58087. /**
  58088. * Creates a new VREXperienceHelper
  58089. * @see https://doc.babylonjs.com/how_to/webvr_helper
  58090. * @param webVROptions defines the options used to create the new VREXperienceHelper
  58091. * @returns a new VREXperienceHelper
  58092. */
  58093. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  58094. /**
  58095. * Creates a new WebXRDefaultExperience
  58096. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  58097. * @param options experience options
  58098. * @returns a promise for a new WebXRDefaultExperience
  58099. */
  58100. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  58101. }
  58102. }
  58103. declare module BABYLON {
  58104. /**
  58105. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  58106. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  58107. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  58108. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58109. */
  58110. export class VideoDome extends TextureDome<VideoTexture> {
  58111. /**
  58112. * Define the video source as a Monoscopic panoramic 360 video.
  58113. */
  58114. static readonly MODE_MONOSCOPIC: number;
  58115. /**
  58116. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  58117. */
  58118. static readonly MODE_TOPBOTTOM: number;
  58119. /**
  58120. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  58121. */
  58122. static readonly MODE_SIDEBYSIDE: number;
  58123. /**
  58124. * Get the video texture associated with this video dome
  58125. */
  58126. get videoTexture(): VideoTexture;
  58127. /**
  58128. * Get the video mode of this dome
  58129. */
  58130. get videoMode(): number;
  58131. /**
  58132. * Set the video mode of this dome.
  58133. * @see textureMode
  58134. */
  58135. set videoMode(value: number);
  58136. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  58137. }
  58138. }
  58139. declare module BABYLON {
  58140. /**
  58141. * This class can be used to get instrumentation data from a Babylon engine
  58142. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  58143. */
  58144. export class EngineInstrumentation implements IDisposable {
  58145. /**
  58146. * Define the instrumented engine.
  58147. */
  58148. engine: Engine;
  58149. private _captureGPUFrameTime;
  58150. private _gpuFrameTimeToken;
  58151. private _gpuFrameTime;
  58152. private _captureShaderCompilationTime;
  58153. private _shaderCompilationTime;
  58154. private _onBeginFrameObserver;
  58155. private _onEndFrameObserver;
  58156. private _onBeforeShaderCompilationObserver;
  58157. private _onAfterShaderCompilationObserver;
  58158. /**
  58159. * Gets the perf counter used for GPU frame time
  58160. */
  58161. get gpuFrameTimeCounter(): PerfCounter;
  58162. /**
  58163. * Gets the GPU frame time capture status
  58164. */
  58165. get captureGPUFrameTime(): boolean;
  58166. /**
  58167. * Enable or disable the GPU frame time capture
  58168. */
  58169. set captureGPUFrameTime(value: boolean);
  58170. /**
  58171. * Gets the perf counter used for shader compilation time
  58172. */
  58173. get shaderCompilationTimeCounter(): PerfCounter;
  58174. /**
  58175. * Gets the shader compilation time capture status
  58176. */
  58177. get captureShaderCompilationTime(): boolean;
  58178. /**
  58179. * Enable or disable the shader compilation time capture
  58180. */
  58181. set captureShaderCompilationTime(value: boolean);
  58182. /**
  58183. * Instantiates a new engine instrumentation.
  58184. * This class can be used to get instrumentation data from a Babylon engine
  58185. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  58186. * @param engine Defines the engine to instrument
  58187. */
  58188. constructor(
  58189. /**
  58190. * Define the instrumented engine.
  58191. */
  58192. engine: Engine);
  58193. /**
  58194. * Dispose and release associated resources.
  58195. */
  58196. dispose(): void;
  58197. }
  58198. }
  58199. declare module BABYLON {
  58200. /**
  58201. * This class can be used to get instrumentation data from a Babylon engine
  58202. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58203. */
  58204. export class SceneInstrumentation implements IDisposable {
  58205. /**
  58206. * Defines the scene to instrument
  58207. */
  58208. scene: Scene;
  58209. private _captureActiveMeshesEvaluationTime;
  58210. private _activeMeshesEvaluationTime;
  58211. private _captureRenderTargetsRenderTime;
  58212. private _renderTargetsRenderTime;
  58213. private _captureFrameTime;
  58214. private _frameTime;
  58215. private _captureRenderTime;
  58216. private _renderTime;
  58217. private _captureInterFrameTime;
  58218. private _interFrameTime;
  58219. private _captureParticlesRenderTime;
  58220. private _particlesRenderTime;
  58221. private _captureSpritesRenderTime;
  58222. private _spritesRenderTime;
  58223. private _capturePhysicsTime;
  58224. private _physicsTime;
  58225. private _captureAnimationsTime;
  58226. private _animationsTime;
  58227. private _captureCameraRenderTime;
  58228. private _cameraRenderTime;
  58229. private _onBeforeActiveMeshesEvaluationObserver;
  58230. private _onAfterActiveMeshesEvaluationObserver;
  58231. private _onBeforeRenderTargetsRenderObserver;
  58232. private _onAfterRenderTargetsRenderObserver;
  58233. private _onAfterRenderObserver;
  58234. private _onBeforeDrawPhaseObserver;
  58235. private _onAfterDrawPhaseObserver;
  58236. private _onBeforeAnimationsObserver;
  58237. private _onBeforeParticlesRenderingObserver;
  58238. private _onAfterParticlesRenderingObserver;
  58239. private _onBeforeSpritesRenderingObserver;
  58240. private _onAfterSpritesRenderingObserver;
  58241. private _onBeforePhysicsObserver;
  58242. private _onAfterPhysicsObserver;
  58243. private _onAfterAnimationsObserver;
  58244. private _onBeforeCameraRenderObserver;
  58245. private _onAfterCameraRenderObserver;
  58246. /**
  58247. * Gets the perf counter used for active meshes evaluation time
  58248. */
  58249. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  58250. /**
  58251. * Gets the active meshes evaluation time capture status
  58252. */
  58253. get captureActiveMeshesEvaluationTime(): boolean;
  58254. /**
  58255. * Enable or disable the active meshes evaluation time capture
  58256. */
  58257. set captureActiveMeshesEvaluationTime(value: boolean);
  58258. /**
  58259. * Gets the perf counter used for render targets render time
  58260. */
  58261. get renderTargetsRenderTimeCounter(): PerfCounter;
  58262. /**
  58263. * Gets the render targets render time capture status
  58264. */
  58265. get captureRenderTargetsRenderTime(): boolean;
  58266. /**
  58267. * Enable or disable the render targets render time capture
  58268. */
  58269. set captureRenderTargetsRenderTime(value: boolean);
  58270. /**
  58271. * Gets the perf counter used for particles render time
  58272. */
  58273. get particlesRenderTimeCounter(): PerfCounter;
  58274. /**
  58275. * Gets the particles render time capture status
  58276. */
  58277. get captureParticlesRenderTime(): boolean;
  58278. /**
  58279. * Enable or disable the particles render time capture
  58280. */
  58281. set captureParticlesRenderTime(value: boolean);
  58282. /**
  58283. * Gets the perf counter used for sprites render time
  58284. */
  58285. get spritesRenderTimeCounter(): PerfCounter;
  58286. /**
  58287. * Gets the sprites render time capture status
  58288. */
  58289. get captureSpritesRenderTime(): boolean;
  58290. /**
  58291. * Enable or disable the sprites render time capture
  58292. */
  58293. set captureSpritesRenderTime(value: boolean);
  58294. /**
  58295. * Gets the perf counter used for physics time
  58296. */
  58297. get physicsTimeCounter(): PerfCounter;
  58298. /**
  58299. * Gets the physics time capture status
  58300. */
  58301. get capturePhysicsTime(): boolean;
  58302. /**
  58303. * Enable or disable the physics time capture
  58304. */
  58305. set capturePhysicsTime(value: boolean);
  58306. /**
  58307. * Gets the perf counter used for animations time
  58308. */
  58309. get animationsTimeCounter(): PerfCounter;
  58310. /**
  58311. * Gets the animations time capture status
  58312. */
  58313. get captureAnimationsTime(): boolean;
  58314. /**
  58315. * Enable or disable the animations time capture
  58316. */
  58317. set captureAnimationsTime(value: boolean);
  58318. /**
  58319. * Gets the perf counter used for frame time capture
  58320. */
  58321. get frameTimeCounter(): PerfCounter;
  58322. /**
  58323. * Gets the frame time capture status
  58324. */
  58325. get captureFrameTime(): boolean;
  58326. /**
  58327. * Enable or disable the frame time capture
  58328. */
  58329. set captureFrameTime(value: boolean);
  58330. /**
  58331. * Gets the perf counter used for inter-frames time capture
  58332. */
  58333. get interFrameTimeCounter(): PerfCounter;
  58334. /**
  58335. * Gets the inter-frames time capture status
  58336. */
  58337. get captureInterFrameTime(): boolean;
  58338. /**
  58339. * Enable or disable the inter-frames time capture
  58340. */
  58341. set captureInterFrameTime(value: boolean);
  58342. /**
  58343. * Gets the perf counter used for render time capture
  58344. */
  58345. get renderTimeCounter(): PerfCounter;
  58346. /**
  58347. * Gets the render time capture status
  58348. */
  58349. get captureRenderTime(): boolean;
  58350. /**
  58351. * Enable or disable the render time capture
  58352. */
  58353. set captureRenderTime(value: boolean);
  58354. /**
  58355. * Gets the perf counter used for camera render time capture
  58356. */
  58357. get cameraRenderTimeCounter(): PerfCounter;
  58358. /**
  58359. * Gets the camera render time capture status
  58360. */
  58361. get captureCameraRenderTime(): boolean;
  58362. /**
  58363. * Enable or disable the camera render time capture
  58364. */
  58365. set captureCameraRenderTime(value: boolean);
  58366. /**
  58367. * Gets the perf counter used for draw calls
  58368. */
  58369. get drawCallsCounter(): PerfCounter;
  58370. /**
  58371. * Instantiates a new scene instrumentation.
  58372. * This class can be used to get instrumentation data from a Babylon engine
  58373. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58374. * @param scene Defines the scene to instrument
  58375. */
  58376. constructor(
  58377. /**
  58378. * Defines the scene to instrument
  58379. */
  58380. scene: Scene);
  58381. /**
  58382. * Dispose and release associated resources.
  58383. */
  58384. dispose(): void;
  58385. }
  58386. }
  58387. declare module BABYLON {
  58388. /** @hidden */
  58389. export var glowMapGenerationPixelShader: {
  58390. name: string;
  58391. shader: string;
  58392. };
  58393. }
  58394. declare module BABYLON {
  58395. /** @hidden */
  58396. export var glowMapGenerationVertexShader: {
  58397. name: string;
  58398. shader: string;
  58399. };
  58400. }
  58401. declare module BABYLON {
  58402. /**
  58403. * Effect layer options. This helps customizing the behaviour
  58404. * of the effect layer.
  58405. */
  58406. export interface IEffectLayerOptions {
  58407. /**
  58408. * Multiplication factor apply to the canvas size to compute the render target size
  58409. * used to generated the objects (the smaller the faster).
  58410. */
  58411. mainTextureRatio: number;
  58412. /**
  58413. * Enforces a fixed size texture to ensure effect stability across devices.
  58414. */
  58415. mainTextureFixedSize?: number;
  58416. /**
  58417. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  58418. */
  58419. alphaBlendingMode: number;
  58420. /**
  58421. * The camera attached to the layer.
  58422. */
  58423. camera: Nullable<Camera>;
  58424. /**
  58425. * The rendering group to draw the layer in.
  58426. */
  58427. renderingGroupId: number;
  58428. }
  58429. /**
  58430. * The effect layer Helps adding post process effect blended with the main pass.
  58431. *
  58432. * This can be for instance use to generate glow or higlight effects on the scene.
  58433. *
  58434. * The effect layer class can not be used directly and is intented to inherited from to be
  58435. * customized per effects.
  58436. */
  58437. export abstract class EffectLayer {
  58438. private _vertexBuffers;
  58439. private _indexBuffer;
  58440. private _cachedDefines;
  58441. private _effectLayerMapGenerationEffect;
  58442. private _effectLayerOptions;
  58443. private _mergeEffect;
  58444. protected _scene: Scene;
  58445. protected _engine: Engine;
  58446. protected _maxSize: number;
  58447. protected _mainTextureDesiredSize: ISize;
  58448. protected _mainTexture: RenderTargetTexture;
  58449. protected _shouldRender: boolean;
  58450. protected _postProcesses: PostProcess[];
  58451. protected _textures: BaseTexture[];
  58452. protected _emissiveTextureAndColor: {
  58453. texture: Nullable<BaseTexture>;
  58454. color: Color4;
  58455. };
  58456. /**
  58457. * The name of the layer
  58458. */
  58459. name: string;
  58460. /**
  58461. * The clear color of the texture used to generate the glow map.
  58462. */
  58463. neutralColor: Color4;
  58464. /**
  58465. * Specifies whether the highlight layer is enabled or not.
  58466. */
  58467. isEnabled: boolean;
  58468. /**
  58469. * Gets the camera attached to the layer.
  58470. */
  58471. get camera(): Nullable<Camera>;
  58472. /**
  58473. * Gets the rendering group id the layer should render in.
  58474. */
  58475. get renderingGroupId(): number;
  58476. set renderingGroupId(renderingGroupId: number);
  58477. /**
  58478. * An event triggered when the effect layer has been disposed.
  58479. */
  58480. onDisposeObservable: Observable<EffectLayer>;
  58481. /**
  58482. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  58483. */
  58484. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  58485. /**
  58486. * An event triggered when the generated texture is being merged in the scene.
  58487. */
  58488. onBeforeComposeObservable: Observable<EffectLayer>;
  58489. /**
  58490. * An event triggered when the mesh is rendered into the effect render target.
  58491. */
  58492. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  58493. /**
  58494. * An event triggered after the mesh has been rendered into the effect render target.
  58495. */
  58496. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  58497. /**
  58498. * An event triggered when the generated texture has been merged in the scene.
  58499. */
  58500. onAfterComposeObservable: Observable<EffectLayer>;
  58501. /**
  58502. * An event triggered when the efffect layer changes its size.
  58503. */
  58504. onSizeChangedObservable: Observable<EffectLayer>;
  58505. /** @hidden */
  58506. static _SceneComponentInitialization: (scene: Scene) => void;
  58507. /**
  58508. * Instantiates a new effect Layer and references it in the scene.
  58509. * @param name The name of the layer
  58510. * @param scene The scene to use the layer in
  58511. */
  58512. constructor(
  58513. /** The Friendly of the effect in the scene */
  58514. name: string, scene: Scene);
  58515. /**
  58516. * Get the effect name of the layer.
  58517. * @return The effect name
  58518. */
  58519. abstract getEffectName(): string;
  58520. /**
  58521. * Checks for the readiness of the element composing the layer.
  58522. * @param subMesh the mesh to check for
  58523. * @param useInstances specify whether or not to use instances to render the mesh
  58524. * @return true if ready otherwise, false
  58525. */
  58526. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58527. /**
  58528. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  58529. * @returns true if the effect requires stencil during the main canvas render pass.
  58530. */
  58531. abstract needStencil(): boolean;
  58532. /**
  58533. * Create the merge effect. This is the shader use to blit the information back
  58534. * to the main canvas at the end of the scene rendering.
  58535. * @returns The effect containing the shader used to merge the effect on the main canvas
  58536. */
  58537. protected abstract _createMergeEffect(): Effect;
  58538. /**
  58539. * Creates the render target textures and post processes used in the effect layer.
  58540. */
  58541. protected abstract _createTextureAndPostProcesses(): void;
  58542. /**
  58543. * Implementation specific of rendering the generating effect on the main canvas.
  58544. * @param effect The effect used to render through
  58545. */
  58546. protected abstract _internalRender(effect: Effect): void;
  58547. /**
  58548. * Sets the required values for both the emissive texture and and the main color.
  58549. */
  58550. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58551. /**
  58552. * Free any resources and references associated to a mesh.
  58553. * Internal use
  58554. * @param mesh The mesh to free.
  58555. */
  58556. abstract _disposeMesh(mesh: Mesh): void;
  58557. /**
  58558. * Serializes this layer (Glow or Highlight for example)
  58559. * @returns a serialized layer object
  58560. */
  58561. abstract serialize?(): any;
  58562. /**
  58563. * Initializes the effect layer with the required options.
  58564. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  58565. */
  58566. protected _init(options: Partial<IEffectLayerOptions>): void;
  58567. /**
  58568. * Generates the index buffer of the full screen quad blending to the main canvas.
  58569. */
  58570. private _generateIndexBuffer;
  58571. /**
  58572. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  58573. */
  58574. private _generateVertexBuffer;
  58575. /**
  58576. * Sets the main texture desired size which is the closest power of two
  58577. * of the engine canvas size.
  58578. */
  58579. private _setMainTextureSize;
  58580. /**
  58581. * Creates the main texture for the effect layer.
  58582. */
  58583. protected _createMainTexture(): void;
  58584. /**
  58585. * Adds specific effects defines.
  58586. * @param defines The defines to add specifics to.
  58587. */
  58588. protected _addCustomEffectDefines(defines: string[]): void;
  58589. /**
  58590. * Checks for the readiness of the element composing the layer.
  58591. * @param subMesh the mesh to check for
  58592. * @param useInstances specify whether or not to use instances to render the mesh
  58593. * @param emissiveTexture the associated emissive texture used to generate the glow
  58594. * @return true if ready otherwise, false
  58595. */
  58596. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  58597. /**
  58598. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  58599. */
  58600. render(): void;
  58601. /**
  58602. * Determine if a given mesh will be used in the current effect.
  58603. * @param mesh mesh to test
  58604. * @returns true if the mesh will be used
  58605. */
  58606. hasMesh(mesh: AbstractMesh): boolean;
  58607. /**
  58608. * Returns true if the layer contains information to display, otherwise false.
  58609. * @returns true if the glow layer should be rendered
  58610. */
  58611. shouldRender(): boolean;
  58612. /**
  58613. * Returns true if the mesh should render, otherwise false.
  58614. * @param mesh The mesh to render
  58615. * @returns true if it should render otherwise false
  58616. */
  58617. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  58618. /**
  58619. * Returns true if the mesh can be rendered, otherwise false.
  58620. * @param mesh The mesh to render
  58621. * @param material The material used on the mesh
  58622. * @returns true if it can be rendered otherwise false
  58623. */
  58624. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58625. /**
  58626. * Returns true if the mesh should render, otherwise false.
  58627. * @param mesh The mesh to render
  58628. * @returns true if it should render otherwise false
  58629. */
  58630. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  58631. /**
  58632. * Renders the submesh passed in parameter to the generation map.
  58633. */
  58634. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  58635. /**
  58636. * Defines whether the current material of the mesh should be use to render the effect.
  58637. * @param mesh defines the current mesh to render
  58638. */
  58639. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  58640. /**
  58641. * Rebuild the required buffers.
  58642. * @hidden Internal use only.
  58643. */
  58644. _rebuild(): void;
  58645. /**
  58646. * Dispose only the render target textures and post process.
  58647. */
  58648. private _disposeTextureAndPostProcesses;
  58649. /**
  58650. * Dispose the highlight layer and free resources.
  58651. */
  58652. dispose(): void;
  58653. /**
  58654. * Gets the class name of the effect layer
  58655. * @returns the string with the class name of the effect layer
  58656. */
  58657. getClassName(): string;
  58658. /**
  58659. * Creates an effect layer from parsed effect layer data
  58660. * @param parsedEffectLayer defines effect layer data
  58661. * @param scene defines the current scene
  58662. * @param rootUrl defines the root URL containing the effect layer information
  58663. * @returns a parsed effect Layer
  58664. */
  58665. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  58666. }
  58667. }
  58668. declare module BABYLON {
  58669. interface AbstractScene {
  58670. /**
  58671. * The list of effect layers (highlights/glow) added to the scene
  58672. * @see https://doc.babylonjs.com/how_to/highlight_layer
  58673. * @see https://doc.babylonjs.com/how_to/glow_layer
  58674. */
  58675. effectLayers: Array<EffectLayer>;
  58676. /**
  58677. * Removes the given effect layer from this scene.
  58678. * @param toRemove defines the effect layer to remove
  58679. * @returns the index of the removed effect layer
  58680. */
  58681. removeEffectLayer(toRemove: EffectLayer): number;
  58682. /**
  58683. * Adds the given effect layer to this scene
  58684. * @param newEffectLayer defines the effect layer to add
  58685. */
  58686. addEffectLayer(newEffectLayer: EffectLayer): void;
  58687. }
  58688. /**
  58689. * Defines the layer scene component responsible to manage any effect layers
  58690. * in a given scene.
  58691. */
  58692. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  58693. /**
  58694. * The component name helpfull to identify the component in the list of scene components.
  58695. */
  58696. readonly name: string;
  58697. /**
  58698. * The scene the component belongs to.
  58699. */
  58700. scene: Scene;
  58701. private _engine;
  58702. private _renderEffects;
  58703. private _needStencil;
  58704. private _previousStencilState;
  58705. /**
  58706. * Creates a new instance of the component for the given scene
  58707. * @param scene Defines the scene to register the component in
  58708. */
  58709. constructor(scene: Scene);
  58710. /**
  58711. * Registers the component in a given scene
  58712. */
  58713. register(): void;
  58714. /**
  58715. * Rebuilds the elements related to this component in case of
  58716. * context lost for instance.
  58717. */
  58718. rebuild(): void;
  58719. /**
  58720. * Serializes the component data to the specified json object
  58721. * @param serializationObject The object to serialize to
  58722. */
  58723. serialize(serializationObject: any): void;
  58724. /**
  58725. * Adds all the elements from the container to the scene
  58726. * @param container the container holding the elements
  58727. */
  58728. addFromContainer(container: AbstractScene): void;
  58729. /**
  58730. * Removes all the elements in the container from the scene
  58731. * @param container contains the elements to remove
  58732. * @param dispose if the removed element should be disposed (default: false)
  58733. */
  58734. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58735. /**
  58736. * Disposes the component and the associated ressources.
  58737. */
  58738. dispose(): void;
  58739. private _isReadyForMesh;
  58740. private _renderMainTexture;
  58741. private _setStencil;
  58742. private _setStencilBack;
  58743. private _draw;
  58744. private _drawCamera;
  58745. private _drawRenderingGroup;
  58746. }
  58747. }
  58748. declare module BABYLON {
  58749. /** @hidden */
  58750. export var glowMapMergePixelShader: {
  58751. name: string;
  58752. shader: string;
  58753. };
  58754. }
  58755. declare module BABYLON {
  58756. /** @hidden */
  58757. export var glowMapMergeVertexShader: {
  58758. name: string;
  58759. shader: string;
  58760. };
  58761. }
  58762. declare module BABYLON {
  58763. interface AbstractScene {
  58764. /**
  58765. * Return a the first highlight layer of the scene with a given name.
  58766. * @param name The name of the highlight layer to look for.
  58767. * @return The highlight layer if found otherwise null.
  58768. */
  58769. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  58770. }
  58771. /**
  58772. * Glow layer options. This helps customizing the behaviour
  58773. * of the glow layer.
  58774. */
  58775. export interface IGlowLayerOptions {
  58776. /**
  58777. * Multiplication factor apply to the canvas size to compute the render target size
  58778. * used to generated the glowing objects (the smaller the faster).
  58779. */
  58780. mainTextureRatio: number;
  58781. /**
  58782. * Enforces a fixed size texture to ensure resize independant blur.
  58783. */
  58784. mainTextureFixedSize?: number;
  58785. /**
  58786. * How big is the kernel of the blur texture.
  58787. */
  58788. blurKernelSize: number;
  58789. /**
  58790. * The camera attached to the layer.
  58791. */
  58792. camera: Nullable<Camera>;
  58793. /**
  58794. * Enable MSAA by chosing the number of samples.
  58795. */
  58796. mainTextureSamples?: number;
  58797. /**
  58798. * The rendering group to draw the layer in.
  58799. */
  58800. renderingGroupId: number;
  58801. }
  58802. /**
  58803. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  58804. *
  58805. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  58806. *
  58807. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  58808. */
  58809. export class GlowLayer extends EffectLayer {
  58810. /**
  58811. * Effect Name of the layer.
  58812. */
  58813. static readonly EffectName: string;
  58814. /**
  58815. * The default blur kernel size used for the glow.
  58816. */
  58817. static DefaultBlurKernelSize: number;
  58818. /**
  58819. * The default texture size ratio used for the glow.
  58820. */
  58821. static DefaultTextureRatio: number;
  58822. /**
  58823. * Sets the kernel size of the blur.
  58824. */
  58825. set blurKernelSize(value: number);
  58826. /**
  58827. * Gets the kernel size of the blur.
  58828. */
  58829. get blurKernelSize(): number;
  58830. /**
  58831. * Sets the glow intensity.
  58832. */
  58833. set intensity(value: number);
  58834. /**
  58835. * Gets the glow intensity.
  58836. */
  58837. get intensity(): number;
  58838. private _options;
  58839. private _intensity;
  58840. private _horizontalBlurPostprocess1;
  58841. private _verticalBlurPostprocess1;
  58842. private _horizontalBlurPostprocess2;
  58843. private _verticalBlurPostprocess2;
  58844. private _blurTexture1;
  58845. private _blurTexture2;
  58846. private _postProcesses1;
  58847. private _postProcesses2;
  58848. private _includedOnlyMeshes;
  58849. private _excludedMeshes;
  58850. private _meshesUsingTheirOwnMaterials;
  58851. /**
  58852. * Callback used to let the user override the color selection on a per mesh basis
  58853. */
  58854. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  58855. /**
  58856. * Callback used to let the user override the texture selection on a per mesh basis
  58857. */
  58858. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  58859. /**
  58860. * Instantiates a new glow Layer and references it to the scene.
  58861. * @param name The name of the layer
  58862. * @param scene The scene to use the layer in
  58863. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  58864. */
  58865. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  58866. /**
  58867. * Get the effect name of the layer.
  58868. * @return The effect name
  58869. */
  58870. getEffectName(): string;
  58871. /**
  58872. * Create the merge effect. This is the shader use to blit the information back
  58873. * to the main canvas at the end of the scene rendering.
  58874. */
  58875. protected _createMergeEffect(): Effect;
  58876. /**
  58877. * Creates the render target textures and post processes used in the glow layer.
  58878. */
  58879. protected _createTextureAndPostProcesses(): void;
  58880. /**
  58881. * Checks for the readiness of the element composing the layer.
  58882. * @param subMesh the mesh to check for
  58883. * @param useInstances specify wether or not to use instances to render the mesh
  58884. * @param emissiveTexture the associated emissive texture used to generate the glow
  58885. * @return true if ready otherwise, false
  58886. */
  58887. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58888. /**
  58889. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  58890. */
  58891. needStencil(): boolean;
  58892. /**
  58893. * Returns true if the mesh can be rendered, otherwise false.
  58894. * @param mesh The mesh to render
  58895. * @param material The material used on the mesh
  58896. * @returns true if it can be rendered otherwise false
  58897. */
  58898. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58899. /**
  58900. * Implementation specific of rendering the generating effect on the main canvas.
  58901. * @param effect The effect used to render through
  58902. */
  58903. protected _internalRender(effect: Effect): void;
  58904. /**
  58905. * Sets the required values for both the emissive texture and and the main color.
  58906. */
  58907. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58908. /**
  58909. * Returns true if the mesh should render, otherwise false.
  58910. * @param mesh The mesh to render
  58911. * @returns true if it should render otherwise false
  58912. */
  58913. protected _shouldRenderMesh(mesh: Mesh): boolean;
  58914. /**
  58915. * Adds specific effects defines.
  58916. * @param defines The defines to add specifics to.
  58917. */
  58918. protected _addCustomEffectDefines(defines: string[]): void;
  58919. /**
  58920. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  58921. * @param mesh The mesh to exclude from the glow layer
  58922. */
  58923. addExcludedMesh(mesh: Mesh): void;
  58924. /**
  58925. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  58926. * @param mesh The mesh to remove
  58927. */
  58928. removeExcludedMesh(mesh: Mesh): void;
  58929. /**
  58930. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  58931. * @param mesh The mesh to include in the glow layer
  58932. */
  58933. addIncludedOnlyMesh(mesh: Mesh): void;
  58934. /**
  58935. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  58936. * @param mesh The mesh to remove
  58937. */
  58938. removeIncludedOnlyMesh(mesh: Mesh): void;
  58939. /**
  58940. * Determine if a given mesh will be used in the glow layer
  58941. * @param mesh The mesh to test
  58942. * @returns true if the mesh will be highlighted by the current glow layer
  58943. */
  58944. hasMesh(mesh: AbstractMesh): boolean;
  58945. /**
  58946. * Defines whether the current material of the mesh should be use to render the effect.
  58947. * @param mesh defines the current mesh to render
  58948. */
  58949. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  58950. /**
  58951. * Add a mesh to be rendered through its own material and not with emissive only.
  58952. * @param mesh The mesh for which we need to use its material
  58953. */
  58954. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  58955. /**
  58956. * Remove a mesh from being rendered through its own material and not with emissive only.
  58957. * @param mesh The mesh for which we need to not use its material
  58958. */
  58959. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  58960. /**
  58961. * Free any resources and references associated to a mesh.
  58962. * Internal use
  58963. * @param mesh The mesh to free.
  58964. * @hidden
  58965. */
  58966. _disposeMesh(mesh: Mesh): void;
  58967. /**
  58968. * Gets the class name of the effect layer
  58969. * @returns the string with the class name of the effect layer
  58970. */
  58971. getClassName(): string;
  58972. /**
  58973. * Serializes this glow layer
  58974. * @returns a serialized glow layer object
  58975. */
  58976. serialize(): any;
  58977. /**
  58978. * Creates a Glow Layer from parsed glow layer data
  58979. * @param parsedGlowLayer defines glow layer data
  58980. * @param scene defines the current scene
  58981. * @param rootUrl defines the root URL containing the glow layer information
  58982. * @returns a parsed Glow Layer
  58983. */
  58984. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  58985. }
  58986. }
  58987. declare module BABYLON {
  58988. /** @hidden */
  58989. export var glowBlurPostProcessPixelShader: {
  58990. name: string;
  58991. shader: string;
  58992. };
  58993. }
  58994. declare module BABYLON {
  58995. interface AbstractScene {
  58996. /**
  58997. * Return a the first highlight layer of the scene with a given name.
  58998. * @param name The name of the highlight layer to look for.
  58999. * @return The highlight layer if found otherwise null.
  59000. */
  59001. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  59002. }
  59003. /**
  59004. * Highlight layer options. This helps customizing the behaviour
  59005. * of the highlight layer.
  59006. */
  59007. export interface IHighlightLayerOptions {
  59008. /**
  59009. * Multiplication factor apply to the canvas size to compute the render target size
  59010. * used to generated the glowing objects (the smaller the faster).
  59011. */
  59012. mainTextureRatio: number;
  59013. /**
  59014. * Enforces a fixed size texture to ensure resize independant blur.
  59015. */
  59016. mainTextureFixedSize?: number;
  59017. /**
  59018. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  59019. * of the picture to blur (the smaller the faster).
  59020. */
  59021. blurTextureSizeRatio: number;
  59022. /**
  59023. * How big in texel of the blur texture is the vertical blur.
  59024. */
  59025. blurVerticalSize: number;
  59026. /**
  59027. * How big in texel of the blur texture is the horizontal blur.
  59028. */
  59029. blurHorizontalSize: number;
  59030. /**
  59031. * Alpha blending mode used to apply the blur. Default is combine.
  59032. */
  59033. alphaBlendingMode: number;
  59034. /**
  59035. * The camera attached to the layer.
  59036. */
  59037. camera: Nullable<Camera>;
  59038. /**
  59039. * Should we display highlight as a solid stroke?
  59040. */
  59041. isStroke?: boolean;
  59042. /**
  59043. * The rendering group to draw the layer in.
  59044. */
  59045. renderingGroupId: number;
  59046. }
  59047. /**
  59048. * The highlight layer Helps adding a glow effect around a mesh.
  59049. *
  59050. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  59051. * glowy meshes to your scene.
  59052. *
  59053. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  59054. */
  59055. export class HighlightLayer extends EffectLayer {
  59056. name: string;
  59057. /**
  59058. * Effect Name of the highlight layer.
  59059. */
  59060. static readonly EffectName: string;
  59061. /**
  59062. * The neutral color used during the preparation of the glow effect.
  59063. * This is black by default as the blend operation is a blend operation.
  59064. */
  59065. static NeutralColor: Color4;
  59066. /**
  59067. * Stencil value used for glowing meshes.
  59068. */
  59069. static GlowingMeshStencilReference: number;
  59070. /**
  59071. * Stencil value used for the other meshes in the scene.
  59072. */
  59073. static NormalMeshStencilReference: number;
  59074. /**
  59075. * Specifies whether or not the inner glow is ACTIVE in the layer.
  59076. */
  59077. innerGlow: boolean;
  59078. /**
  59079. * Specifies whether or not the outer glow is ACTIVE in the layer.
  59080. */
  59081. outerGlow: boolean;
  59082. /**
  59083. * Specifies the horizontal size of the blur.
  59084. */
  59085. set blurHorizontalSize(value: number);
  59086. /**
  59087. * Specifies the vertical size of the blur.
  59088. */
  59089. set blurVerticalSize(value: number);
  59090. /**
  59091. * Gets the horizontal size of the blur.
  59092. */
  59093. get blurHorizontalSize(): number;
  59094. /**
  59095. * Gets the vertical size of the blur.
  59096. */
  59097. get blurVerticalSize(): number;
  59098. /**
  59099. * An event triggered when the highlight layer is being blurred.
  59100. */
  59101. onBeforeBlurObservable: Observable<HighlightLayer>;
  59102. /**
  59103. * An event triggered when the highlight layer has been blurred.
  59104. */
  59105. onAfterBlurObservable: Observable<HighlightLayer>;
  59106. private _instanceGlowingMeshStencilReference;
  59107. private _options;
  59108. private _downSamplePostprocess;
  59109. private _horizontalBlurPostprocess;
  59110. private _verticalBlurPostprocess;
  59111. private _blurTexture;
  59112. private _meshes;
  59113. private _excludedMeshes;
  59114. /**
  59115. * Instantiates a new highlight Layer and references it to the scene..
  59116. * @param name The name of the layer
  59117. * @param scene The scene to use the layer in
  59118. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  59119. */
  59120. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  59121. /**
  59122. * Get the effect name of the layer.
  59123. * @return The effect name
  59124. */
  59125. getEffectName(): string;
  59126. /**
  59127. * Create the merge effect. This is the shader use to blit the information back
  59128. * to the main canvas at the end of the scene rendering.
  59129. */
  59130. protected _createMergeEffect(): Effect;
  59131. /**
  59132. * Creates the render target textures and post processes used in the highlight layer.
  59133. */
  59134. protected _createTextureAndPostProcesses(): void;
  59135. /**
  59136. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  59137. */
  59138. needStencil(): boolean;
  59139. /**
  59140. * Checks for the readiness of the element composing the layer.
  59141. * @param subMesh the mesh to check for
  59142. * @param useInstances specify wether or not to use instances to render the mesh
  59143. * @param emissiveTexture the associated emissive texture used to generate the glow
  59144. * @return true if ready otherwise, false
  59145. */
  59146. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59147. /**
  59148. * Implementation specific of rendering the generating effect on the main canvas.
  59149. * @param effect The effect used to render through
  59150. */
  59151. protected _internalRender(effect: Effect): void;
  59152. /**
  59153. * Returns true if the layer contains information to display, otherwise false.
  59154. */
  59155. shouldRender(): boolean;
  59156. /**
  59157. * Returns true if the mesh should render, otherwise false.
  59158. * @param mesh The mesh to render
  59159. * @returns true if it should render otherwise false
  59160. */
  59161. protected _shouldRenderMesh(mesh: Mesh): boolean;
  59162. /**
  59163. * Returns true if the mesh can be rendered, otherwise false.
  59164. * @param mesh The mesh to render
  59165. * @param material The material used on the mesh
  59166. * @returns true if it can be rendered otherwise false
  59167. */
  59168. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59169. /**
  59170. * Adds specific effects defines.
  59171. * @param defines The defines to add specifics to.
  59172. */
  59173. protected _addCustomEffectDefines(defines: string[]): void;
  59174. /**
  59175. * Sets the required values for both the emissive texture and and the main color.
  59176. */
  59177. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59178. /**
  59179. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  59180. * @param mesh The mesh to exclude from the highlight layer
  59181. */
  59182. addExcludedMesh(mesh: Mesh): void;
  59183. /**
  59184. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  59185. * @param mesh The mesh to highlight
  59186. */
  59187. removeExcludedMesh(mesh: Mesh): void;
  59188. /**
  59189. * Determine if a given mesh will be highlighted by the current HighlightLayer
  59190. * @param mesh mesh to test
  59191. * @returns true if the mesh will be highlighted by the current HighlightLayer
  59192. */
  59193. hasMesh(mesh: AbstractMesh): boolean;
  59194. /**
  59195. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  59196. * @param mesh The mesh to highlight
  59197. * @param color The color of the highlight
  59198. * @param glowEmissiveOnly Extract the glow from the emissive texture
  59199. */
  59200. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  59201. /**
  59202. * Remove a mesh from the highlight layer in order to make it stop glowing.
  59203. * @param mesh The mesh to highlight
  59204. */
  59205. removeMesh(mesh: Mesh): void;
  59206. /**
  59207. * Remove all the meshes currently referenced in the highlight layer
  59208. */
  59209. removeAllMeshes(): void;
  59210. /**
  59211. * Force the stencil to the normal expected value for none glowing parts
  59212. */
  59213. private _defaultStencilReference;
  59214. /**
  59215. * Free any resources and references associated to a mesh.
  59216. * Internal use
  59217. * @param mesh The mesh to free.
  59218. * @hidden
  59219. */
  59220. _disposeMesh(mesh: Mesh): void;
  59221. /**
  59222. * Dispose the highlight layer and free resources.
  59223. */
  59224. dispose(): void;
  59225. /**
  59226. * Gets the class name of the effect layer
  59227. * @returns the string with the class name of the effect layer
  59228. */
  59229. getClassName(): string;
  59230. /**
  59231. * Serializes this Highlight layer
  59232. * @returns a serialized Highlight layer object
  59233. */
  59234. serialize(): any;
  59235. /**
  59236. * Creates a Highlight layer from parsed Highlight layer data
  59237. * @param parsedHightlightLayer defines the Highlight layer data
  59238. * @param scene defines the current scene
  59239. * @param rootUrl defines the root URL containing the Highlight layer information
  59240. * @returns a parsed Highlight layer
  59241. */
  59242. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  59243. }
  59244. }
  59245. declare module BABYLON {
  59246. interface AbstractScene {
  59247. /**
  59248. * The list of layers (background and foreground) of the scene
  59249. */
  59250. layers: Array<Layer>;
  59251. }
  59252. /**
  59253. * Defines the layer scene component responsible to manage any layers
  59254. * in a given scene.
  59255. */
  59256. export class LayerSceneComponent implements ISceneComponent {
  59257. /**
  59258. * The component name helpfull to identify the component in the list of scene components.
  59259. */
  59260. readonly name: string;
  59261. /**
  59262. * The scene the component belongs to.
  59263. */
  59264. scene: Scene;
  59265. private _engine;
  59266. /**
  59267. * Creates a new instance of the component for the given scene
  59268. * @param scene Defines the scene to register the component in
  59269. */
  59270. constructor(scene: Scene);
  59271. /**
  59272. * Registers the component in a given scene
  59273. */
  59274. register(): void;
  59275. /**
  59276. * Rebuilds the elements related to this component in case of
  59277. * context lost for instance.
  59278. */
  59279. rebuild(): void;
  59280. /**
  59281. * Disposes the component and the associated ressources.
  59282. */
  59283. dispose(): void;
  59284. private _draw;
  59285. private _drawCameraPredicate;
  59286. private _drawCameraBackground;
  59287. private _drawCameraForeground;
  59288. private _drawRenderTargetPredicate;
  59289. private _drawRenderTargetBackground;
  59290. private _drawRenderTargetForeground;
  59291. /**
  59292. * Adds all the elements from the container to the scene
  59293. * @param container the container holding the elements
  59294. */
  59295. addFromContainer(container: AbstractScene): void;
  59296. /**
  59297. * Removes all the elements in the container from the scene
  59298. * @param container contains the elements to remove
  59299. * @param dispose if the removed element should be disposed (default: false)
  59300. */
  59301. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59302. }
  59303. }
  59304. declare module BABYLON {
  59305. /** @hidden */
  59306. export var layerPixelShader: {
  59307. name: string;
  59308. shader: string;
  59309. };
  59310. }
  59311. declare module BABYLON {
  59312. /** @hidden */
  59313. export var layerVertexShader: {
  59314. name: string;
  59315. shader: string;
  59316. };
  59317. }
  59318. declare module BABYLON {
  59319. /**
  59320. * This represents a full screen 2d layer.
  59321. * This can be useful to display a picture in the background of your scene for instance.
  59322. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59323. */
  59324. export class Layer {
  59325. /**
  59326. * Define the name of the layer.
  59327. */
  59328. name: string;
  59329. /**
  59330. * Define the texture the layer should display.
  59331. */
  59332. texture: Nullable<Texture>;
  59333. /**
  59334. * Is the layer in background or foreground.
  59335. */
  59336. isBackground: boolean;
  59337. /**
  59338. * Define the color of the layer (instead of texture).
  59339. */
  59340. color: Color4;
  59341. /**
  59342. * Define the scale of the layer in order to zoom in out of the texture.
  59343. */
  59344. scale: Vector2;
  59345. /**
  59346. * Define an offset for the layer in order to shift the texture.
  59347. */
  59348. offset: Vector2;
  59349. /**
  59350. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  59351. */
  59352. alphaBlendingMode: number;
  59353. /**
  59354. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  59355. * Alpha test will not mix with the background color in case of transparency.
  59356. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  59357. */
  59358. alphaTest: boolean;
  59359. /**
  59360. * Define a mask to restrict the layer to only some of the scene cameras.
  59361. */
  59362. layerMask: number;
  59363. /**
  59364. * Define the list of render target the layer is visible into.
  59365. */
  59366. renderTargetTextures: RenderTargetTexture[];
  59367. /**
  59368. * Define if the layer is only used in renderTarget or if it also
  59369. * renders in the main frame buffer of the canvas.
  59370. */
  59371. renderOnlyInRenderTargetTextures: boolean;
  59372. private _scene;
  59373. private _vertexBuffers;
  59374. private _indexBuffer;
  59375. private _effect;
  59376. private _previousDefines;
  59377. /**
  59378. * An event triggered when the layer is disposed.
  59379. */
  59380. onDisposeObservable: Observable<Layer>;
  59381. private _onDisposeObserver;
  59382. /**
  59383. * Back compatibility with callback before the onDisposeObservable existed.
  59384. * The set callback will be triggered when the layer has been disposed.
  59385. */
  59386. set onDispose(callback: () => void);
  59387. /**
  59388. * An event triggered before rendering the scene
  59389. */
  59390. onBeforeRenderObservable: Observable<Layer>;
  59391. private _onBeforeRenderObserver;
  59392. /**
  59393. * Back compatibility with callback before the onBeforeRenderObservable existed.
  59394. * The set callback will be triggered just before rendering the layer.
  59395. */
  59396. set onBeforeRender(callback: () => void);
  59397. /**
  59398. * An event triggered after rendering the scene
  59399. */
  59400. onAfterRenderObservable: Observable<Layer>;
  59401. private _onAfterRenderObserver;
  59402. /**
  59403. * Back compatibility with callback before the onAfterRenderObservable existed.
  59404. * The set callback will be triggered just after rendering the layer.
  59405. */
  59406. set onAfterRender(callback: () => void);
  59407. /**
  59408. * Instantiates a new layer.
  59409. * This represents a full screen 2d layer.
  59410. * This can be useful to display a picture in the background of your scene for instance.
  59411. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59412. * @param name Define the name of the layer in the scene
  59413. * @param imgUrl Define the url of the texture to display in the layer
  59414. * @param scene Define the scene the layer belongs to
  59415. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  59416. * @param color Defines a color for the layer
  59417. */
  59418. constructor(
  59419. /**
  59420. * Define the name of the layer.
  59421. */
  59422. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  59423. private _createIndexBuffer;
  59424. /** @hidden */
  59425. _rebuild(): void;
  59426. /**
  59427. * Renders the layer in the scene.
  59428. */
  59429. render(): void;
  59430. /**
  59431. * Disposes and releases the associated ressources.
  59432. */
  59433. dispose(): void;
  59434. }
  59435. }
  59436. declare module BABYLON {
  59437. /** @hidden */
  59438. export var lensFlarePixelShader: {
  59439. name: string;
  59440. shader: string;
  59441. };
  59442. }
  59443. declare module BABYLON {
  59444. /** @hidden */
  59445. export var lensFlareVertexShader: {
  59446. name: string;
  59447. shader: string;
  59448. };
  59449. }
  59450. declare module BABYLON {
  59451. /**
  59452. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  59453. * It is usually composed of several `lensFlare`.
  59454. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59455. */
  59456. export class LensFlareSystem {
  59457. /**
  59458. * Define the name of the lens flare system
  59459. */
  59460. name: string;
  59461. /**
  59462. * List of lens flares used in this system.
  59463. */
  59464. lensFlares: LensFlare[];
  59465. /**
  59466. * Define a limit from the border the lens flare can be visible.
  59467. */
  59468. borderLimit: number;
  59469. /**
  59470. * Define a viewport border we do not want to see the lens flare in.
  59471. */
  59472. viewportBorder: number;
  59473. /**
  59474. * Define a predicate which could limit the list of meshes able to occlude the effect.
  59475. */
  59476. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  59477. /**
  59478. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  59479. */
  59480. layerMask: number;
  59481. /**
  59482. * Define the id of the lens flare system in the scene.
  59483. * (equal to name by default)
  59484. */
  59485. id: string;
  59486. private _scene;
  59487. private _emitter;
  59488. private _vertexBuffers;
  59489. private _indexBuffer;
  59490. private _effect;
  59491. private _positionX;
  59492. private _positionY;
  59493. private _isEnabled;
  59494. /** @hidden */
  59495. static _SceneComponentInitialization: (scene: Scene) => void;
  59496. /**
  59497. * Instantiates a lens flare system.
  59498. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  59499. * It is usually composed of several `lensFlare`.
  59500. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59501. * @param name Define the name of the lens flare system in the scene
  59502. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  59503. * @param scene Define the scene the lens flare system belongs to
  59504. */
  59505. constructor(
  59506. /**
  59507. * Define the name of the lens flare system
  59508. */
  59509. name: string, emitter: any, scene: Scene);
  59510. /**
  59511. * Define if the lens flare system is enabled.
  59512. */
  59513. get isEnabled(): boolean;
  59514. set isEnabled(value: boolean);
  59515. /**
  59516. * Get the scene the effects belongs to.
  59517. * @returns the scene holding the lens flare system
  59518. */
  59519. getScene(): Scene;
  59520. /**
  59521. * Get the emitter of the lens flare system.
  59522. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  59523. * @returns the emitter of the lens flare system
  59524. */
  59525. getEmitter(): any;
  59526. /**
  59527. * Set the emitter of the lens flare system.
  59528. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  59529. * @param newEmitter Define the new emitter of the system
  59530. */
  59531. setEmitter(newEmitter: any): void;
  59532. /**
  59533. * Get the lens flare system emitter position.
  59534. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  59535. * @returns the position
  59536. */
  59537. getEmitterPosition(): Vector3;
  59538. /**
  59539. * @hidden
  59540. */
  59541. computeEffectivePosition(globalViewport: Viewport): boolean;
  59542. /** @hidden */
  59543. _isVisible(): boolean;
  59544. /**
  59545. * @hidden
  59546. */
  59547. render(): boolean;
  59548. /**
  59549. * Dispose and release the lens flare with its associated resources.
  59550. */
  59551. dispose(): void;
  59552. /**
  59553. * Parse a lens flare system from a JSON repressentation
  59554. * @param parsedLensFlareSystem Define the JSON to parse
  59555. * @param scene Define the scene the parsed system should be instantiated in
  59556. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  59557. * @returns the parsed system
  59558. */
  59559. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  59560. /**
  59561. * Serialize the current Lens Flare System into a JSON representation.
  59562. * @returns the serialized JSON
  59563. */
  59564. serialize(): any;
  59565. }
  59566. }
  59567. declare module BABYLON {
  59568. /**
  59569. * This represents one of the lens effect in a `lensFlareSystem`.
  59570. * It controls one of the indiviual texture used in the effect.
  59571. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59572. */
  59573. export class LensFlare {
  59574. /**
  59575. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  59576. */
  59577. size: number;
  59578. /**
  59579. * 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.
  59580. */
  59581. position: number;
  59582. /**
  59583. * Define the lens color.
  59584. */
  59585. color: Color3;
  59586. /**
  59587. * Define the lens texture.
  59588. */
  59589. texture: Nullable<Texture>;
  59590. /**
  59591. * Define the alpha mode to render this particular lens.
  59592. */
  59593. alphaMode: number;
  59594. private _system;
  59595. /**
  59596. * Creates a new Lens Flare.
  59597. * This represents one of the lens effect in a `lensFlareSystem`.
  59598. * It controls one of the indiviual texture used in the effect.
  59599. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59600. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  59601. * @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.
  59602. * @param color Define the lens color
  59603. * @param imgUrl Define the lens texture url
  59604. * @param system Define the `lensFlareSystem` this flare is part of
  59605. * @returns The newly created Lens Flare
  59606. */
  59607. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  59608. /**
  59609. * Instantiates a new Lens Flare.
  59610. * This represents one of the lens effect in a `lensFlareSystem`.
  59611. * It controls one of the indiviual texture used in the effect.
  59612. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59613. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  59614. * @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.
  59615. * @param color Define the lens color
  59616. * @param imgUrl Define the lens texture url
  59617. * @param system Define the `lensFlareSystem` this flare is part of
  59618. */
  59619. constructor(
  59620. /**
  59621. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  59622. */
  59623. size: number,
  59624. /**
  59625. * 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.
  59626. */
  59627. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  59628. /**
  59629. * Dispose and release the lens flare with its associated resources.
  59630. */
  59631. dispose(): void;
  59632. }
  59633. }
  59634. declare module BABYLON {
  59635. interface AbstractScene {
  59636. /**
  59637. * The list of lens flare system added to the scene
  59638. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59639. */
  59640. lensFlareSystems: Array<LensFlareSystem>;
  59641. /**
  59642. * Removes the given lens flare system from this scene.
  59643. * @param toRemove The lens flare system to remove
  59644. * @returns The index of the removed lens flare system
  59645. */
  59646. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  59647. /**
  59648. * Adds the given lens flare system to this scene
  59649. * @param newLensFlareSystem The lens flare system to add
  59650. */
  59651. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  59652. /**
  59653. * Gets a lens flare system using its name
  59654. * @param name defines the name to look for
  59655. * @returns the lens flare system or null if not found
  59656. */
  59657. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  59658. /**
  59659. * Gets a lens flare system using its id
  59660. * @param id defines the id to look for
  59661. * @returns the lens flare system or null if not found
  59662. */
  59663. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  59664. }
  59665. /**
  59666. * Defines the lens flare scene component responsible to manage any lens flares
  59667. * in a given scene.
  59668. */
  59669. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  59670. /**
  59671. * The component name helpfull to identify the component in the list of scene components.
  59672. */
  59673. readonly name: string;
  59674. /**
  59675. * The scene the component belongs to.
  59676. */
  59677. scene: Scene;
  59678. /**
  59679. * Creates a new instance of the component for the given scene
  59680. * @param scene Defines the scene to register the component in
  59681. */
  59682. constructor(scene: Scene);
  59683. /**
  59684. * Registers the component in a given scene
  59685. */
  59686. register(): void;
  59687. /**
  59688. * Rebuilds the elements related to this component in case of
  59689. * context lost for instance.
  59690. */
  59691. rebuild(): void;
  59692. /**
  59693. * Adds all the elements from the container to the scene
  59694. * @param container the container holding the elements
  59695. */
  59696. addFromContainer(container: AbstractScene): void;
  59697. /**
  59698. * Removes all the elements in the container from the scene
  59699. * @param container contains the elements to remove
  59700. * @param dispose if the removed element should be disposed (default: false)
  59701. */
  59702. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59703. /**
  59704. * Serializes the component data to the specified json object
  59705. * @param serializationObject The object to serialize to
  59706. */
  59707. serialize(serializationObject: any): void;
  59708. /**
  59709. * Disposes the component and the associated ressources.
  59710. */
  59711. dispose(): void;
  59712. private _draw;
  59713. }
  59714. }
  59715. declare module BABYLON {
  59716. /** @hidden */
  59717. export var depthPixelShader: {
  59718. name: string;
  59719. shader: string;
  59720. };
  59721. }
  59722. declare module BABYLON {
  59723. /** @hidden */
  59724. export var depthVertexShader: {
  59725. name: string;
  59726. shader: string;
  59727. };
  59728. }
  59729. declare module BABYLON {
  59730. /**
  59731. * This represents a depth renderer in Babylon.
  59732. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  59733. */
  59734. export class DepthRenderer {
  59735. private _scene;
  59736. private _depthMap;
  59737. private _effect;
  59738. private readonly _storeNonLinearDepth;
  59739. private readonly _clearColor;
  59740. /** Get if the depth renderer is using packed depth or not */
  59741. readonly isPacked: boolean;
  59742. private _cachedDefines;
  59743. private _camera;
  59744. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  59745. enabled: boolean;
  59746. /**
  59747. * Specifiess that the depth renderer will only be used within
  59748. * the camera it is created for.
  59749. * This can help forcing its rendering during the camera processing.
  59750. */
  59751. useOnlyInActiveCamera: boolean;
  59752. /** @hidden */
  59753. static _SceneComponentInitialization: (scene: Scene) => void;
  59754. /**
  59755. * Instantiates a depth renderer
  59756. * @param scene The scene the renderer belongs to
  59757. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  59758. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  59759. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  59760. */
  59761. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  59762. /**
  59763. * Creates the depth rendering effect and checks if the effect is ready.
  59764. * @param subMesh The submesh to be used to render the depth map of
  59765. * @param useInstances If multiple world instances should be used
  59766. * @returns if the depth renderer is ready to render the depth map
  59767. */
  59768. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59769. /**
  59770. * Gets the texture which the depth map will be written to.
  59771. * @returns The depth map texture
  59772. */
  59773. getDepthMap(): RenderTargetTexture;
  59774. /**
  59775. * Disposes of the depth renderer.
  59776. */
  59777. dispose(): void;
  59778. }
  59779. }
  59780. declare module BABYLON {
  59781. /** @hidden */
  59782. export var minmaxReduxPixelShader: {
  59783. name: string;
  59784. shader: string;
  59785. };
  59786. }
  59787. declare module BABYLON {
  59788. /**
  59789. * This class computes a min/max reduction from a texture: it means it computes the minimum
  59790. * and maximum values from all values of the texture.
  59791. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  59792. * The source values are read from the red channel of the texture.
  59793. */
  59794. export class MinMaxReducer {
  59795. /**
  59796. * Observable triggered when the computation has been performed
  59797. */
  59798. onAfterReductionPerformed: Observable<{
  59799. min: number;
  59800. max: number;
  59801. }>;
  59802. protected _camera: Camera;
  59803. protected _sourceTexture: Nullable<RenderTargetTexture>;
  59804. protected _reductionSteps: Nullable<Array<PostProcess>>;
  59805. protected _postProcessManager: PostProcessManager;
  59806. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  59807. protected _forceFullscreenViewport: boolean;
  59808. /**
  59809. * Creates a min/max reducer
  59810. * @param camera The camera to use for the post processes
  59811. */
  59812. constructor(camera: Camera);
  59813. /**
  59814. * Gets the texture used to read the values from.
  59815. */
  59816. get sourceTexture(): Nullable<RenderTargetTexture>;
  59817. /**
  59818. * Sets the source texture to read the values from.
  59819. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  59820. * because in such textures '1' value must not be taken into account to compute the maximum
  59821. * as this value is used to clear the texture.
  59822. * Note that the computation is not activated by calling this function, you must call activate() for that!
  59823. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  59824. * @param depthRedux Indicates if the texture is a depth texture or not
  59825. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  59826. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  59827. */
  59828. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  59829. /**
  59830. * Defines the refresh rate of the computation.
  59831. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  59832. */
  59833. get refreshRate(): number;
  59834. set refreshRate(value: number);
  59835. protected _activated: boolean;
  59836. /**
  59837. * Gets the activation status of the reducer
  59838. */
  59839. get activated(): boolean;
  59840. /**
  59841. * Activates the reduction computation.
  59842. * When activated, the observers registered in onAfterReductionPerformed are
  59843. * called after the compuation is performed
  59844. */
  59845. activate(): void;
  59846. /**
  59847. * Deactivates the reduction computation.
  59848. */
  59849. deactivate(): void;
  59850. /**
  59851. * Disposes the min/max reducer
  59852. * @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.
  59853. */
  59854. dispose(disposeAll?: boolean): void;
  59855. }
  59856. }
  59857. declare module BABYLON {
  59858. /**
  59859. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  59860. */
  59861. export class DepthReducer extends MinMaxReducer {
  59862. private _depthRenderer;
  59863. private _depthRendererId;
  59864. /**
  59865. * Gets the depth renderer used for the computation.
  59866. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  59867. */
  59868. get depthRenderer(): Nullable<DepthRenderer>;
  59869. /**
  59870. * Creates a depth reducer
  59871. * @param camera The camera used to render the depth texture
  59872. */
  59873. constructor(camera: Camera);
  59874. /**
  59875. * Sets the depth renderer to use to generate the depth map
  59876. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  59877. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  59878. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  59879. */
  59880. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  59881. /** @hidden */
  59882. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  59883. /**
  59884. * Activates the reduction computation.
  59885. * When activated, the observers registered in onAfterReductionPerformed are
  59886. * called after the compuation is performed
  59887. */
  59888. activate(): void;
  59889. /**
  59890. * Deactivates the reduction computation.
  59891. */
  59892. deactivate(): void;
  59893. /**
  59894. * Disposes the depth reducer
  59895. * @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.
  59896. */
  59897. dispose(disposeAll?: boolean): void;
  59898. }
  59899. }
  59900. declare module BABYLON {
  59901. /**
  59902. * A CSM implementation allowing casting shadows on large scenes.
  59903. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  59904. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  59905. */
  59906. export class CascadedShadowGenerator extends ShadowGenerator {
  59907. private static readonly frustumCornersNDCSpace;
  59908. /**
  59909. * Name of the CSM class
  59910. */
  59911. static CLASSNAME: string;
  59912. /**
  59913. * Defines the default number of cascades used by the CSM.
  59914. */
  59915. static readonly DEFAULT_CASCADES_COUNT: number;
  59916. /**
  59917. * Defines the minimum number of cascades used by the CSM.
  59918. */
  59919. static readonly MIN_CASCADES_COUNT: number;
  59920. /**
  59921. * Defines the maximum number of cascades used by the CSM.
  59922. */
  59923. static readonly MAX_CASCADES_COUNT: number;
  59924. protected _validateFilter(filter: number): number;
  59925. /**
  59926. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  59927. */
  59928. penumbraDarkness: number;
  59929. private _numCascades;
  59930. /**
  59931. * Gets or set the number of cascades used by the CSM.
  59932. */
  59933. get numCascades(): number;
  59934. set numCascades(value: number);
  59935. /**
  59936. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  59937. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  59938. */
  59939. stabilizeCascades: boolean;
  59940. private _freezeShadowCastersBoundingInfo;
  59941. private _freezeShadowCastersBoundingInfoObservable;
  59942. /**
  59943. * Enables or disables the shadow casters bounding info computation.
  59944. * If your shadow casters don't move, you can disable this feature.
  59945. * If it is enabled, the bounding box computation is done every frame.
  59946. */
  59947. get freezeShadowCastersBoundingInfo(): boolean;
  59948. set freezeShadowCastersBoundingInfo(freeze: boolean);
  59949. private _scbiMin;
  59950. private _scbiMax;
  59951. protected _computeShadowCastersBoundingInfo(): void;
  59952. protected _shadowCastersBoundingInfo: BoundingInfo;
  59953. /**
  59954. * Gets or sets the shadow casters bounding info.
  59955. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  59956. * so that the system won't overwrite the bounds you provide
  59957. */
  59958. get shadowCastersBoundingInfo(): BoundingInfo;
  59959. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  59960. protected _breaksAreDirty: boolean;
  59961. protected _minDistance: number;
  59962. protected _maxDistance: number;
  59963. /**
  59964. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  59965. *
  59966. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  59967. * If you don't know these values, simply leave them to their defaults and don't call this function.
  59968. * @param min minimal distance for the breaks (default to 0.)
  59969. * @param max maximal distance for the breaks (default to 1.)
  59970. */
  59971. setMinMaxDistance(min: number, max: number): void;
  59972. /** Gets the minimal distance used in the cascade break computation */
  59973. get minDistance(): number;
  59974. /** Gets the maximal distance used in the cascade break computation */
  59975. get maxDistance(): number;
  59976. /**
  59977. * Gets the class name of that object
  59978. * @returns "CascadedShadowGenerator"
  59979. */
  59980. getClassName(): string;
  59981. private _cascadeMinExtents;
  59982. private _cascadeMaxExtents;
  59983. /**
  59984. * Gets a cascade minimum extents
  59985. * @param cascadeIndex index of the cascade
  59986. * @returns the minimum cascade extents
  59987. */
  59988. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  59989. /**
  59990. * Gets a cascade maximum extents
  59991. * @param cascadeIndex index of the cascade
  59992. * @returns the maximum cascade extents
  59993. */
  59994. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  59995. private _cascades;
  59996. private _currentLayer;
  59997. private _viewSpaceFrustumsZ;
  59998. private _viewMatrices;
  59999. private _projectionMatrices;
  60000. private _transformMatrices;
  60001. private _transformMatricesAsArray;
  60002. private _frustumLengths;
  60003. private _lightSizeUVCorrection;
  60004. private _depthCorrection;
  60005. private _frustumCornersWorldSpace;
  60006. private _frustumCenter;
  60007. private _shadowCameraPos;
  60008. private _shadowMaxZ;
  60009. /**
  60010. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  60011. * It defaults to camera.maxZ
  60012. */
  60013. get shadowMaxZ(): number;
  60014. /**
  60015. * Sets the shadow max z distance.
  60016. */
  60017. set shadowMaxZ(value: number);
  60018. protected _debug: boolean;
  60019. /**
  60020. * Gets or sets the debug flag.
  60021. * When enabled, the cascades are materialized by different colors on the screen.
  60022. */
  60023. get debug(): boolean;
  60024. set debug(dbg: boolean);
  60025. private _depthClamp;
  60026. /**
  60027. * Gets or sets the depth clamping value.
  60028. *
  60029. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  60030. * to account for the shadow casters far away.
  60031. *
  60032. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  60033. */
  60034. get depthClamp(): boolean;
  60035. set depthClamp(value: boolean);
  60036. private _cascadeBlendPercentage;
  60037. /**
  60038. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  60039. * It defaults to 0.1 (10% blending).
  60040. */
  60041. get cascadeBlendPercentage(): number;
  60042. set cascadeBlendPercentage(value: number);
  60043. private _lambda;
  60044. /**
  60045. * Gets or set the lambda parameter.
  60046. * This parameter is used to split the camera frustum and create the cascades.
  60047. * 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.
  60048. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  60049. */
  60050. get lambda(): number;
  60051. set lambda(value: number);
  60052. /**
  60053. * Gets the view matrix corresponding to a given cascade
  60054. * @param cascadeNum cascade to retrieve the view matrix from
  60055. * @returns the cascade view matrix
  60056. */
  60057. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  60058. /**
  60059. * Gets the projection matrix corresponding to a given cascade
  60060. * @param cascadeNum cascade to retrieve the projection matrix from
  60061. * @returns the cascade projection matrix
  60062. */
  60063. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  60064. /**
  60065. * Gets the transformation matrix corresponding to a given cascade
  60066. * @param cascadeNum cascade to retrieve the transformation matrix from
  60067. * @returns the cascade transformation matrix
  60068. */
  60069. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  60070. private _depthRenderer;
  60071. /**
  60072. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  60073. *
  60074. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  60075. *
  60076. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  60077. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  60078. * @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
  60079. */
  60080. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  60081. private _depthReducer;
  60082. private _autoCalcDepthBounds;
  60083. /**
  60084. * Gets or sets the autoCalcDepthBounds property.
  60085. *
  60086. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  60087. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  60088. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  60089. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  60090. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  60091. */
  60092. get autoCalcDepthBounds(): boolean;
  60093. set autoCalcDepthBounds(value: boolean);
  60094. /**
  60095. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  60096. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  60097. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  60098. * for setting the refresh rate on the renderer yourself!
  60099. */
  60100. get autoCalcDepthBoundsRefreshRate(): number;
  60101. set autoCalcDepthBoundsRefreshRate(value: number);
  60102. /**
  60103. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  60104. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  60105. * you change the camera near/far planes!
  60106. */
  60107. splitFrustum(): void;
  60108. private _splitFrustum;
  60109. private _computeMatrices;
  60110. private _computeFrustumInWorldSpace;
  60111. private _computeCascadeFrustum;
  60112. /**
  60113. * Support test.
  60114. */
  60115. static get IsSupported(): boolean;
  60116. /** @hidden */
  60117. static _SceneComponentInitialization: (scene: Scene) => void;
  60118. /**
  60119. * Creates a Cascaded Shadow Generator object.
  60120. * A ShadowGenerator is the required tool to use the shadows.
  60121. * Each directional light casting shadows needs to use its own ShadowGenerator.
  60122. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  60123. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  60124. * @param light The directional light object generating the shadows.
  60125. * @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.
  60126. */
  60127. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  60128. protected _initializeGenerator(): void;
  60129. protected _createTargetRenderTexture(): void;
  60130. protected _initializeShadowMap(): void;
  60131. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  60132. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  60133. /**
  60134. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  60135. * @param defines Defines of the material we want to update
  60136. * @param lightIndex Index of the light in the enabled light list of the material
  60137. */
  60138. prepareDefines(defines: any, lightIndex: number): void;
  60139. /**
  60140. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  60141. * defined in the generator but impacting the effect).
  60142. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  60143. * @param effect The effect we are binfing the information for
  60144. */
  60145. bindShadowLight(lightIndex: string, effect: Effect): void;
  60146. /**
  60147. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  60148. * (eq to view projection * shadow projection matrices)
  60149. * @returns The transform matrix used to create the shadow map
  60150. */
  60151. getTransformMatrix(): Matrix;
  60152. /**
  60153. * Disposes the ShadowGenerator.
  60154. * Returns nothing.
  60155. */
  60156. dispose(): void;
  60157. /**
  60158. * Serializes the shadow generator setup to a json object.
  60159. * @returns The serialized JSON object
  60160. */
  60161. serialize(): any;
  60162. /**
  60163. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  60164. * @param parsedShadowGenerator The JSON object to parse
  60165. * @param scene The scene to create the shadow map for
  60166. * @returns The parsed shadow generator
  60167. */
  60168. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  60169. }
  60170. }
  60171. declare module BABYLON {
  60172. /**
  60173. * Defines the shadow generator component responsible to manage any shadow generators
  60174. * in a given scene.
  60175. */
  60176. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  60177. /**
  60178. * The component name helpfull to identify the component in the list of scene components.
  60179. */
  60180. readonly name: string;
  60181. /**
  60182. * The scene the component belongs to.
  60183. */
  60184. scene: Scene;
  60185. /**
  60186. * Creates a new instance of the component for the given scene
  60187. * @param scene Defines the scene to register the component in
  60188. */
  60189. constructor(scene: Scene);
  60190. /**
  60191. * Registers the component in a given scene
  60192. */
  60193. register(): void;
  60194. /**
  60195. * Rebuilds the elements related to this component in case of
  60196. * context lost for instance.
  60197. */
  60198. rebuild(): void;
  60199. /**
  60200. * Serializes the component data to the specified json object
  60201. * @param serializationObject The object to serialize to
  60202. */
  60203. serialize(serializationObject: any): void;
  60204. /**
  60205. * Adds all the elements from the container to the scene
  60206. * @param container the container holding the elements
  60207. */
  60208. addFromContainer(container: AbstractScene): void;
  60209. /**
  60210. * Removes all the elements in the container from the scene
  60211. * @param container contains the elements to remove
  60212. * @param dispose if the removed element should be disposed (default: false)
  60213. */
  60214. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60215. /**
  60216. * Rebuilds the elements related to this component in case of
  60217. * context lost for instance.
  60218. */
  60219. dispose(): void;
  60220. private _gatherRenderTargets;
  60221. }
  60222. }
  60223. declare module BABYLON {
  60224. /**
  60225. * A point light is a light defined by an unique point in world space.
  60226. * The light is emitted in every direction from this point.
  60227. * A good example of a point light is a standard light bulb.
  60228. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60229. */
  60230. export class PointLight extends ShadowLight {
  60231. private _shadowAngle;
  60232. /**
  60233. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60234. * This specifies what angle the shadow will use to be created.
  60235. *
  60236. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  60237. */
  60238. get shadowAngle(): number;
  60239. /**
  60240. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60241. * This specifies what angle the shadow will use to be created.
  60242. *
  60243. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  60244. */
  60245. set shadowAngle(value: number);
  60246. /**
  60247. * Gets the direction if it has been set.
  60248. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60249. */
  60250. get direction(): Vector3;
  60251. /**
  60252. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60253. */
  60254. set direction(value: Vector3);
  60255. /**
  60256. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  60257. * A PointLight emits the light in every direction.
  60258. * It can cast shadows.
  60259. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  60260. * ```javascript
  60261. * var pointLight = new PointLight("pl", camera.position, scene);
  60262. * ```
  60263. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60264. * @param name The light friendly name
  60265. * @param position The position of the point light in the scene
  60266. * @param scene The scene the lights belongs to
  60267. */
  60268. constructor(name: string, position: Vector3, scene: Scene);
  60269. /**
  60270. * Returns the string "PointLight"
  60271. * @returns the class name
  60272. */
  60273. getClassName(): string;
  60274. /**
  60275. * Returns the integer 0.
  60276. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60277. */
  60278. getTypeID(): number;
  60279. /**
  60280. * Specifies wether or not the shadowmap should be a cube texture.
  60281. * @returns true if the shadowmap needs to be a cube texture.
  60282. */
  60283. needCube(): boolean;
  60284. /**
  60285. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  60286. * @param faceIndex The index of the face we are computed the direction to generate shadow
  60287. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  60288. */
  60289. getShadowDirection(faceIndex?: number): Vector3;
  60290. /**
  60291. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  60292. * - fov = PI / 2
  60293. * - aspect ratio : 1.0
  60294. * - z-near and far equal to the active camera minZ and maxZ.
  60295. * Returns the PointLight.
  60296. */
  60297. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60298. protected _buildUniformLayout(): void;
  60299. /**
  60300. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  60301. * @param effect The effect to update
  60302. * @param lightIndex The index of the light in the effect to update
  60303. * @returns The point light
  60304. */
  60305. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  60306. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  60307. /**
  60308. * Prepares the list of defines specific to the light type.
  60309. * @param defines the list of defines
  60310. * @param lightIndex defines the index of the light for the effect
  60311. */
  60312. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60313. }
  60314. }
  60315. declare module BABYLON {
  60316. /**
  60317. * Header information of HDR texture files.
  60318. */
  60319. export interface HDRInfo {
  60320. /**
  60321. * The height of the texture in pixels.
  60322. */
  60323. height: number;
  60324. /**
  60325. * The width of the texture in pixels.
  60326. */
  60327. width: number;
  60328. /**
  60329. * The index of the beginning of the data in the binary file.
  60330. */
  60331. dataPosition: number;
  60332. }
  60333. /**
  60334. * This groups tools to convert HDR texture to native colors array.
  60335. */
  60336. export class HDRTools {
  60337. private static Ldexp;
  60338. private static Rgbe2float;
  60339. private static readStringLine;
  60340. /**
  60341. * Reads header information from an RGBE texture stored in a native array.
  60342. * More information on this format are available here:
  60343. * https://en.wikipedia.org/wiki/RGBE_image_format
  60344. *
  60345. * @param uint8array The binary file stored in native array.
  60346. * @return The header information.
  60347. */
  60348. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  60349. /**
  60350. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  60351. * This RGBE texture needs to store the information as a panorama.
  60352. *
  60353. * More information on this format are available here:
  60354. * https://en.wikipedia.org/wiki/RGBE_image_format
  60355. *
  60356. * @param buffer The binary file stored in an array buffer.
  60357. * @param size The expected size of the extracted cubemap.
  60358. * @return The Cube Map information.
  60359. */
  60360. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  60361. /**
  60362. * Returns the pixels data extracted from an RGBE texture.
  60363. * This pixels will be stored left to right up to down in the R G B order in one array.
  60364. *
  60365. * More information on this format are available here:
  60366. * https://en.wikipedia.org/wiki/RGBE_image_format
  60367. *
  60368. * @param uint8array The binary file stored in an array buffer.
  60369. * @param hdrInfo The header information of the file.
  60370. * @return The pixels data in RGB right to left up to down order.
  60371. */
  60372. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  60373. private static RGBE_ReadPixels_RLE;
  60374. private static RGBE_ReadPixels_NOT_RLE;
  60375. }
  60376. }
  60377. declare module BABYLON {
  60378. /**
  60379. * Effect Render Options
  60380. */
  60381. export interface IEffectRendererOptions {
  60382. /**
  60383. * Defines the vertices positions.
  60384. */
  60385. positions?: number[];
  60386. /**
  60387. * Defines the indices.
  60388. */
  60389. indices?: number[];
  60390. }
  60391. /**
  60392. * Helper class to render one or more effects.
  60393. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  60394. */
  60395. export class EffectRenderer {
  60396. private engine;
  60397. private static _DefaultOptions;
  60398. private _vertexBuffers;
  60399. private _indexBuffer;
  60400. private _fullscreenViewport;
  60401. /**
  60402. * Creates an effect renderer
  60403. * @param engine the engine to use for rendering
  60404. * @param options defines the options of the effect renderer
  60405. */
  60406. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60407. /**
  60408. * Sets the current viewport in normalized coordinates 0-1
  60409. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60410. */
  60411. setViewport(viewport?: Viewport): void;
  60412. /**
  60413. * Binds the embedded attributes buffer to the effect.
  60414. * @param effect Defines the effect to bind the attributes for
  60415. */
  60416. bindBuffers(effect: Effect): void;
  60417. /**
  60418. * Sets the current effect wrapper to use during draw.
  60419. * The effect needs to be ready before calling this api.
  60420. * This also sets the default full screen position attribute.
  60421. * @param effectWrapper Defines the effect to draw with
  60422. */
  60423. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60424. /**
  60425. * Restores engine states
  60426. */
  60427. restoreStates(): void;
  60428. /**
  60429. * Draws a full screen quad.
  60430. */
  60431. draw(): void;
  60432. private isRenderTargetTexture;
  60433. /**
  60434. * renders one or more effects to a specified texture
  60435. * @param effectWrapper the effect to renderer
  60436. * @param outputTexture texture to draw to, if null it will render to the screen.
  60437. */
  60438. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  60439. /**
  60440. * Disposes of the effect renderer
  60441. */
  60442. dispose(): void;
  60443. }
  60444. /**
  60445. * Options to create an EffectWrapper
  60446. */
  60447. interface EffectWrapperCreationOptions {
  60448. /**
  60449. * Engine to use to create the effect
  60450. */
  60451. engine: ThinEngine;
  60452. /**
  60453. * Fragment shader for the effect
  60454. */
  60455. fragmentShader: string;
  60456. /**
  60457. * Use the shader store instead of direct source code
  60458. */
  60459. useShaderStore?: boolean;
  60460. /**
  60461. * Vertex shader for the effect
  60462. */
  60463. vertexShader?: string;
  60464. /**
  60465. * Attributes to use in the shader
  60466. */
  60467. attributeNames?: Array<string>;
  60468. /**
  60469. * Uniforms to use in the shader
  60470. */
  60471. uniformNames?: Array<string>;
  60472. /**
  60473. * Texture sampler names to use in the shader
  60474. */
  60475. samplerNames?: Array<string>;
  60476. /**
  60477. * Defines to use in the shader
  60478. */
  60479. defines?: Array<string>;
  60480. /**
  60481. * Callback when effect is compiled
  60482. */
  60483. onCompiled?: Nullable<(effect: Effect) => void>;
  60484. /**
  60485. * The friendly name of the effect displayed in Spector.
  60486. */
  60487. name?: string;
  60488. }
  60489. /**
  60490. * Wraps an effect to be used for rendering
  60491. */
  60492. export class EffectWrapper {
  60493. /**
  60494. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60495. */
  60496. onApplyObservable: Observable<{}>;
  60497. /**
  60498. * The underlying effect
  60499. */
  60500. effect: Effect;
  60501. /**
  60502. * Creates an effect to be renderer
  60503. * @param creationOptions options to create the effect
  60504. */
  60505. constructor(creationOptions: EffectWrapperCreationOptions);
  60506. /**
  60507. * Disposes of the effect wrapper
  60508. */
  60509. dispose(): void;
  60510. }
  60511. }
  60512. declare module BABYLON {
  60513. /** @hidden */
  60514. export var hdrFilteringVertexShader: {
  60515. name: string;
  60516. shader: string;
  60517. };
  60518. }
  60519. declare module BABYLON {
  60520. /** @hidden */
  60521. export var hdrFilteringPixelShader: {
  60522. name: string;
  60523. shader: string;
  60524. };
  60525. }
  60526. declare module BABYLON {
  60527. /**
  60528. * Options for texture filtering
  60529. */
  60530. interface IHDRFilteringOptions {
  60531. /**
  60532. * Scales pixel intensity for the input HDR map.
  60533. */
  60534. hdrScale?: number;
  60535. /**
  60536. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  60537. */
  60538. quality?: number;
  60539. }
  60540. /**
  60541. * Filters HDR maps to get correct renderings of PBR reflections
  60542. */
  60543. export class HDRFiltering {
  60544. private _engine;
  60545. private _effectRenderer;
  60546. private _effectWrapper;
  60547. private _lodGenerationOffset;
  60548. private _lodGenerationScale;
  60549. /**
  60550. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  60551. * you care about baking speed.
  60552. */
  60553. quality: number;
  60554. /**
  60555. * Scales pixel intensity for the input HDR map.
  60556. */
  60557. hdrScale: number;
  60558. /**
  60559. * Instantiates HDR filter for reflection maps
  60560. *
  60561. * @param engine Thin engine
  60562. * @param options Options
  60563. */
  60564. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  60565. private _createRenderTarget;
  60566. private _prefilterInternal;
  60567. private _createEffect;
  60568. /**
  60569. * Get a value indicating if the filter is ready to be used
  60570. * @param texture Texture to filter
  60571. * @returns true if the filter is ready
  60572. */
  60573. isReady(texture: BaseTexture): boolean;
  60574. /**
  60575. * Prefilters a cube texture to have mipmap levels representing roughness values.
  60576. * Prefiltering will be invoked at the end of next rendering pass.
  60577. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  60578. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  60579. * @param texture Texture to filter
  60580. * @param onFinished Callback when filtering is done
  60581. * @return Promise called when prefiltering is done
  60582. */
  60583. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  60584. }
  60585. }
  60586. declare module BABYLON {
  60587. /**
  60588. * This represents a texture coming from an HDR input.
  60589. *
  60590. * The only supported format is currently panorama picture stored in RGBE format.
  60591. * Example of such files can be found on HDRLib: http://hdrlib.com/
  60592. */
  60593. export class HDRCubeTexture extends BaseTexture {
  60594. private static _facesMapping;
  60595. private _generateHarmonics;
  60596. private _noMipmap;
  60597. private _prefilterOnLoad;
  60598. private _textureMatrix;
  60599. private _size;
  60600. private _onLoad;
  60601. private _onError;
  60602. /**
  60603. * The texture URL.
  60604. */
  60605. url: string;
  60606. protected _isBlocking: boolean;
  60607. /**
  60608. * Sets wether or not the texture is blocking during loading.
  60609. */
  60610. set isBlocking(value: boolean);
  60611. /**
  60612. * Gets wether or not the texture is blocking during loading.
  60613. */
  60614. get isBlocking(): boolean;
  60615. protected _rotationY: number;
  60616. /**
  60617. * Sets texture matrix rotation angle around Y axis in radians.
  60618. */
  60619. set rotationY(value: number);
  60620. /**
  60621. * Gets texture matrix rotation angle around Y axis radians.
  60622. */
  60623. get rotationY(): number;
  60624. /**
  60625. * Gets or sets the center of the bounding box associated with the cube texture
  60626. * It must define where the camera used to render the texture was set
  60627. */
  60628. boundingBoxPosition: Vector3;
  60629. private _boundingBoxSize;
  60630. /**
  60631. * Gets or sets the size of the bounding box associated with the cube texture
  60632. * When defined, the cubemap will switch to local mode
  60633. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  60634. * @example https://www.babylonjs-playground.com/#RNASML
  60635. */
  60636. set boundingBoxSize(value: Vector3);
  60637. get boundingBoxSize(): Vector3;
  60638. /**
  60639. * Instantiates an HDRTexture from the following parameters.
  60640. *
  60641. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  60642. * @param sceneOrEngine The scene or engine the texture will be used in
  60643. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  60644. * @param noMipmap Forces to not generate the mipmap if true
  60645. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  60646. * @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)
  60647. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  60648. */
  60649. 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>);
  60650. /**
  60651. * Get the current class name of the texture useful for serialization or dynamic coding.
  60652. * @returns "HDRCubeTexture"
  60653. */
  60654. getClassName(): string;
  60655. /**
  60656. * Occurs when the file is raw .hdr file.
  60657. */
  60658. private loadTexture;
  60659. clone(): HDRCubeTexture;
  60660. delayLoad(): void;
  60661. /**
  60662. * Get the texture reflection matrix used to rotate/transform the reflection.
  60663. * @returns the reflection matrix
  60664. */
  60665. getReflectionTextureMatrix(): Matrix;
  60666. /**
  60667. * Set the texture reflection matrix used to rotate/transform the reflection.
  60668. * @param value Define the reflection matrix to set
  60669. */
  60670. setReflectionTextureMatrix(value: Matrix): void;
  60671. /**
  60672. * Parses a JSON representation of an HDR Texture in order to create the texture
  60673. * @param parsedTexture Define the JSON representation
  60674. * @param scene Define the scene the texture should be created in
  60675. * @param rootUrl Define the root url in case we need to load relative dependencies
  60676. * @returns the newly created texture after parsing
  60677. */
  60678. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  60679. serialize(): any;
  60680. }
  60681. }
  60682. declare module BABYLON {
  60683. /**
  60684. * Class used to control physics engine
  60685. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  60686. */
  60687. export class PhysicsEngine implements IPhysicsEngine {
  60688. private _physicsPlugin;
  60689. /**
  60690. * Global value used to control the smallest number supported by the simulation
  60691. */
  60692. static Epsilon: number;
  60693. private _impostors;
  60694. private _joints;
  60695. private _subTimeStep;
  60696. /**
  60697. * Gets the gravity vector used by the simulation
  60698. */
  60699. gravity: Vector3;
  60700. /**
  60701. * Factory used to create the default physics plugin.
  60702. * @returns The default physics plugin
  60703. */
  60704. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  60705. /**
  60706. * Creates a new Physics Engine
  60707. * @param gravity defines the gravity vector used by the simulation
  60708. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  60709. */
  60710. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  60711. /**
  60712. * Sets the gravity vector used by the simulation
  60713. * @param gravity defines the gravity vector to use
  60714. */
  60715. setGravity(gravity: Vector3): void;
  60716. /**
  60717. * Set the time step of the physics engine.
  60718. * Default is 1/60.
  60719. * To slow it down, enter 1/600 for example.
  60720. * To speed it up, 1/30
  60721. * @param newTimeStep defines the new timestep to apply to this world.
  60722. */
  60723. setTimeStep(newTimeStep?: number): void;
  60724. /**
  60725. * Get the time step of the physics engine.
  60726. * @returns the current time step
  60727. */
  60728. getTimeStep(): number;
  60729. /**
  60730. * Set the sub time step of the physics engine.
  60731. * Default is 0 meaning there is no sub steps
  60732. * To increase physics resolution precision, set a small value (like 1 ms)
  60733. * @param subTimeStep defines the new sub timestep used for physics resolution.
  60734. */
  60735. setSubTimeStep(subTimeStep?: number): void;
  60736. /**
  60737. * Get the sub time step of the physics engine.
  60738. * @returns the current sub time step
  60739. */
  60740. getSubTimeStep(): number;
  60741. /**
  60742. * Release all resources
  60743. */
  60744. dispose(): void;
  60745. /**
  60746. * Gets the name of the current physics plugin
  60747. * @returns the name of the plugin
  60748. */
  60749. getPhysicsPluginName(): string;
  60750. /**
  60751. * Adding a new impostor for the impostor tracking.
  60752. * This will be done by the impostor itself.
  60753. * @param impostor the impostor to add
  60754. */
  60755. addImpostor(impostor: PhysicsImpostor): void;
  60756. /**
  60757. * Remove an impostor from the engine.
  60758. * This impostor and its mesh will not longer be updated by the physics engine.
  60759. * @param impostor the impostor to remove
  60760. */
  60761. removeImpostor(impostor: PhysicsImpostor): void;
  60762. /**
  60763. * Add a joint to the physics engine
  60764. * @param mainImpostor defines the main impostor to which the joint is added.
  60765. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  60766. * @param joint defines the joint that will connect both impostors.
  60767. */
  60768. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  60769. /**
  60770. * Removes a joint from the simulation
  60771. * @param mainImpostor defines the impostor used with the joint
  60772. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  60773. * @param joint defines the joint to remove
  60774. */
  60775. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  60776. /**
  60777. * Called by the scene. No need to call it.
  60778. * @param delta defines the timespam between frames
  60779. */
  60780. _step(delta: number): void;
  60781. /**
  60782. * Gets the current plugin used to run the simulation
  60783. * @returns current plugin
  60784. */
  60785. getPhysicsPlugin(): IPhysicsEnginePlugin;
  60786. /**
  60787. * Gets the list of physic impostors
  60788. * @returns an array of PhysicsImpostor
  60789. */
  60790. getImpostors(): Array<PhysicsImpostor>;
  60791. /**
  60792. * Gets the impostor for a physics enabled object
  60793. * @param object defines the object impersonated by the impostor
  60794. * @returns the PhysicsImpostor or null if not found
  60795. */
  60796. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  60797. /**
  60798. * Gets the impostor for a physics body object
  60799. * @param body defines physics body used by the impostor
  60800. * @returns the PhysicsImpostor or null if not found
  60801. */
  60802. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  60803. /**
  60804. * Does a raycast in the physics world
  60805. * @param from when should the ray start?
  60806. * @param to when should the ray end?
  60807. * @returns PhysicsRaycastResult
  60808. */
  60809. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60810. }
  60811. }
  60812. declare module BABYLON {
  60813. /** @hidden */
  60814. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  60815. private _useDeltaForWorldStep;
  60816. world: any;
  60817. name: string;
  60818. private _physicsMaterials;
  60819. private _fixedTimeStep;
  60820. private _cannonRaycastResult;
  60821. private _raycastResult;
  60822. private _physicsBodysToRemoveAfterStep;
  60823. private _firstFrame;
  60824. BJSCANNON: any;
  60825. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  60826. setGravity(gravity: Vector3): void;
  60827. setTimeStep(timeStep: number): void;
  60828. getTimeStep(): number;
  60829. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60830. private _removeMarkedPhysicsBodiesFromWorld;
  60831. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60832. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60833. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60834. private _processChildMeshes;
  60835. removePhysicsBody(impostor: PhysicsImpostor): void;
  60836. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60837. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60838. private _addMaterial;
  60839. private _checkWithEpsilon;
  60840. private _createShape;
  60841. private _createHeightmap;
  60842. private _minus90X;
  60843. private _plus90X;
  60844. private _tmpPosition;
  60845. private _tmpDeltaPosition;
  60846. private _tmpUnityRotation;
  60847. private _updatePhysicsBodyTransformation;
  60848. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60849. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60850. isSupported(): boolean;
  60851. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60852. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60853. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60854. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60855. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60856. getBodyMass(impostor: PhysicsImpostor): number;
  60857. getBodyFriction(impostor: PhysicsImpostor): number;
  60858. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60859. getBodyRestitution(impostor: PhysicsImpostor): number;
  60860. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60861. sleepBody(impostor: PhysicsImpostor): void;
  60862. wakeUpBody(impostor: PhysicsImpostor): void;
  60863. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  60864. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  60865. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  60866. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60867. getRadius(impostor: PhysicsImpostor): number;
  60868. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60869. dispose(): void;
  60870. private _extendNamespace;
  60871. /**
  60872. * Does a raycast in the physics world
  60873. * @param from when should the ray start?
  60874. * @param to when should the ray end?
  60875. * @returns PhysicsRaycastResult
  60876. */
  60877. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60878. }
  60879. }
  60880. declare module BABYLON {
  60881. /** @hidden */
  60882. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  60883. private _useDeltaForWorldStep;
  60884. world: any;
  60885. name: string;
  60886. BJSOIMO: any;
  60887. private _raycastResult;
  60888. private _fixedTimeStep;
  60889. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  60890. setGravity(gravity: Vector3): void;
  60891. setTimeStep(timeStep: number): void;
  60892. getTimeStep(): number;
  60893. private _tmpImpostorsArray;
  60894. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60895. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60896. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60897. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60898. private _tmpPositionVector;
  60899. removePhysicsBody(impostor: PhysicsImpostor): void;
  60900. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60901. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60902. isSupported(): boolean;
  60903. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60904. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60905. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60906. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60907. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60908. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60909. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60910. getBodyMass(impostor: PhysicsImpostor): number;
  60911. getBodyFriction(impostor: PhysicsImpostor): number;
  60912. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60913. getBodyRestitution(impostor: PhysicsImpostor): number;
  60914. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60915. sleepBody(impostor: PhysicsImpostor): void;
  60916. wakeUpBody(impostor: PhysicsImpostor): void;
  60917. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  60918. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  60919. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  60920. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60921. getRadius(impostor: PhysicsImpostor): number;
  60922. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60923. dispose(): void;
  60924. /**
  60925. * Does a raycast in the physics world
  60926. * @param from when should the ray start?
  60927. * @param to when should the ray end?
  60928. * @returns PhysicsRaycastResult
  60929. */
  60930. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60931. }
  60932. }
  60933. declare module BABYLON {
  60934. /**
  60935. * AmmoJS Physics plugin
  60936. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  60937. * @see https://github.com/kripken/ammo.js/
  60938. */
  60939. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  60940. private _useDeltaForWorldStep;
  60941. /**
  60942. * Reference to the Ammo library
  60943. */
  60944. bjsAMMO: any;
  60945. /**
  60946. * Created ammoJS world which physics bodies are added to
  60947. */
  60948. world: any;
  60949. /**
  60950. * Name of the plugin
  60951. */
  60952. name: string;
  60953. private _timeStep;
  60954. private _fixedTimeStep;
  60955. private _maxSteps;
  60956. private _tmpQuaternion;
  60957. private _tmpAmmoTransform;
  60958. private _tmpAmmoQuaternion;
  60959. private _tmpAmmoConcreteContactResultCallback;
  60960. private _collisionConfiguration;
  60961. private _dispatcher;
  60962. private _overlappingPairCache;
  60963. private _solver;
  60964. private _softBodySolver;
  60965. private _tmpAmmoVectorA;
  60966. private _tmpAmmoVectorB;
  60967. private _tmpAmmoVectorC;
  60968. private _tmpAmmoVectorD;
  60969. private _tmpContactCallbackResult;
  60970. private _tmpAmmoVectorRCA;
  60971. private _tmpAmmoVectorRCB;
  60972. private _raycastResult;
  60973. private static readonly DISABLE_COLLISION_FLAG;
  60974. private static readonly KINEMATIC_FLAG;
  60975. private static readonly DISABLE_DEACTIVATION_FLAG;
  60976. /**
  60977. * Initializes the ammoJS plugin
  60978. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  60979. * @param ammoInjection can be used to inject your own ammo reference
  60980. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  60981. */
  60982. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  60983. /**
  60984. * Sets the gravity of the physics world (m/(s^2))
  60985. * @param gravity Gravity to set
  60986. */
  60987. setGravity(gravity: Vector3): void;
  60988. /**
  60989. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  60990. * @param timeStep timestep to use in seconds
  60991. */
  60992. setTimeStep(timeStep: number): void;
  60993. /**
  60994. * 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)
  60995. * @param fixedTimeStep fixedTimeStep to use in seconds
  60996. */
  60997. setFixedTimeStep(fixedTimeStep: number): void;
  60998. /**
  60999. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  61000. * @param maxSteps the maximum number of steps by the physics engine per frame
  61001. */
  61002. setMaxSteps(maxSteps: number): void;
  61003. /**
  61004. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  61005. * @returns the current timestep in seconds
  61006. */
  61007. getTimeStep(): number;
  61008. /**
  61009. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  61010. */
  61011. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  61012. private _isImpostorInContact;
  61013. private _isImpostorPairInContact;
  61014. private _stepSimulation;
  61015. /**
  61016. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  61017. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  61018. * After the step the babylon meshes are set to the position of the physics imposters
  61019. * @param delta amount of time to step forward
  61020. * @param impostors array of imposters to update before/after the step
  61021. */
  61022. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61023. /**
  61024. * Update babylon mesh to match physics world object
  61025. * @param impostor imposter to match
  61026. */
  61027. private _afterSoftStep;
  61028. /**
  61029. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61030. * @param impostor imposter to match
  61031. */
  61032. private _ropeStep;
  61033. /**
  61034. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61035. * @param impostor imposter to match
  61036. */
  61037. private _softbodyOrClothStep;
  61038. private _tmpMatrix;
  61039. /**
  61040. * Applies an impulse on the imposter
  61041. * @param impostor imposter to apply impulse to
  61042. * @param force amount of force to be applied to the imposter
  61043. * @param contactPoint the location to apply the impulse on the imposter
  61044. */
  61045. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61046. /**
  61047. * Applies a force on the imposter
  61048. * @param impostor imposter to apply force
  61049. * @param force amount of force to be applied to the imposter
  61050. * @param contactPoint the location to apply the force on the imposter
  61051. */
  61052. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61053. /**
  61054. * Creates a physics body using the plugin
  61055. * @param impostor the imposter to create the physics body on
  61056. */
  61057. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61058. /**
  61059. * Removes the physics body from the imposter and disposes of the body's memory
  61060. * @param impostor imposter to remove the physics body from
  61061. */
  61062. removePhysicsBody(impostor: PhysicsImpostor): void;
  61063. /**
  61064. * Generates a joint
  61065. * @param impostorJoint the imposter joint to create the joint with
  61066. */
  61067. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61068. /**
  61069. * Removes a joint
  61070. * @param impostorJoint the imposter joint to remove the joint from
  61071. */
  61072. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61073. private _addMeshVerts;
  61074. /**
  61075. * Initialise the soft body vertices to match its object's (mesh) vertices
  61076. * Softbody vertices (nodes) are in world space and to match this
  61077. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  61078. * @param impostor to create the softbody for
  61079. */
  61080. private _softVertexData;
  61081. /**
  61082. * Create an impostor's soft body
  61083. * @param impostor to create the softbody for
  61084. */
  61085. private _createSoftbody;
  61086. /**
  61087. * Create cloth for an impostor
  61088. * @param impostor to create the softbody for
  61089. */
  61090. private _createCloth;
  61091. /**
  61092. * Create rope for an impostor
  61093. * @param impostor to create the softbody for
  61094. */
  61095. private _createRope;
  61096. /**
  61097. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  61098. * @param impostor to create the custom physics shape for
  61099. */
  61100. private _createCustom;
  61101. private _addHullVerts;
  61102. private _createShape;
  61103. /**
  61104. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  61105. * @param impostor imposter containing the physics body and babylon object
  61106. */
  61107. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61108. /**
  61109. * Sets the babylon object's position/rotation from the physics body's position/rotation
  61110. * @param impostor imposter containing the physics body and babylon object
  61111. * @param newPosition new position
  61112. * @param newRotation new rotation
  61113. */
  61114. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61115. /**
  61116. * If this plugin is supported
  61117. * @returns true if its supported
  61118. */
  61119. isSupported(): boolean;
  61120. /**
  61121. * Sets the linear velocity of the physics body
  61122. * @param impostor imposter to set the velocity on
  61123. * @param velocity velocity to set
  61124. */
  61125. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61126. /**
  61127. * Sets the angular velocity of the physics body
  61128. * @param impostor imposter to set the velocity on
  61129. * @param velocity velocity to set
  61130. */
  61131. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61132. /**
  61133. * gets the linear velocity
  61134. * @param impostor imposter to get linear velocity from
  61135. * @returns linear velocity
  61136. */
  61137. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61138. /**
  61139. * gets the angular velocity
  61140. * @param impostor imposter to get angular velocity from
  61141. * @returns angular velocity
  61142. */
  61143. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61144. /**
  61145. * Sets the mass of physics body
  61146. * @param impostor imposter to set the mass on
  61147. * @param mass mass to set
  61148. */
  61149. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61150. /**
  61151. * Gets the mass of the physics body
  61152. * @param impostor imposter to get the mass from
  61153. * @returns mass
  61154. */
  61155. getBodyMass(impostor: PhysicsImpostor): number;
  61156. /**
  61157. * Gets friction of the impostor
  61158. * @param impostor impostor to get friction from
  61159. * @returns friction value
  61160. */
  61161. getBodyFriction(impostor: PhysicsImpostor): number;
  61162. /**
  61163. * Sets friction of the impostor
  61164. * @param impostor impostor to set friction on
  61165. * @param friction friction value
  61166. */
  61167. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61168. /**
  61169. * Gets restitution of the impostor
  61170. * @param impostor impostor to get restitution from
  61171. * @returns restitution value
  61172. */
  61173. getBodyRestitution(impostor: PhysicsImpostor): number;
  61174. /**
  61175. * Sets resitution of the impostor
  61176. * @param impostor impostor to set resitution on
  61177. * @param restitution resitution value
  61178. */
  61179. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61180. /**
  61181. * Gets pressure inside the impostor
  61182. * @param impostor impostor to get pressure from
  61183. * @returns pressure value
  61184. */
  61185. getBodyPressure(impostor: PhysicsImpostor): number;
  61186. /**
  61187. * Sets pressure inside a soft body impostor
  61188. * Cloth and rope must remain 0 pressure
  61189. * @param impostor impostor to set pressure on
  61190. * @param pressure pressure value
  61191. */
  61192. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  61193. /**
  61194. * Gets stiffness of the impostor
  61195. * @param impostor impostor to get stiffness from
  61196. * @returns pressure value
  61197. */
  61198. getBodyStiffness(impostor: PhysicsImpostor): number;
  61199. /**
  61200. * Sets stiffness of the impostor
  61201. * @param impostor impostor to set stiffness on
  61202. * @param stiffness stiffness value from 0 to 1
  61203. */
  61204. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  61205. /**
  61206. * Gets velocityIterations of the impostor
  61207. * @param impostor impostor to get velocity iterations from
  61208. * @returns velocityIterations value
  61209. */
  61210. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  61211. /**
  61212. * Sets velocityIterations of the impostor
  61213. * @param impostor impostor to set velocity iterations on
  61214. * @param velocityIterations velocityIterations value
  61215. */
  61216. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  61217. /**
  61218. * Gets positionIterations of the impostor
  61219. * @param impostor impostor to get position iterations from
  61220. * @returns positionIterations value
  61221. */
  61222. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  61223. /**
  61224. * Sets positionIterations of the impostor
  61225. * @param impostor impostor to set position on
  61226. * @param positionIterations positionIterations value
  61227. */
  61228. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  61229. /**
  61230. * Append an anchor to a cloth object
  61231. * @param impostor is the cloth impostor to add anchor to
  61232. * @param otherImpostor is the rigid impostor to anchor to
  61233. * @param width ratio across width from 0 to 1
  61234. * @param height ratio up height from 0 to 1
  61235. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  61236. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  61237. */
  61238. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  61239. /**
  61240. * Append an hook to a rope object
  61241. * @param impostor is the rope impostor to add hook to
  61242. * @param otherImpostor is the rigid impostor to hook to
  61243. * @param length ratio along the rope from 0 to 1
  61244. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  61245. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  61246. */
  61247. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  61248. /**
  61249. * Sleeps the physics body and stops it from being active
  61250. * @param impostor impostor to sleep
  61251. */
  61252. sleepBody(impostor: PhysicsImpostor): void;
  61253. /**
  61254. * Activates the physics body
  61255. * @param impostor impostor to activate
  61256. */
  61257. wakeUpBody(impostor: PhysicsImpostor): void;
  61258. /**
  61259. * Updates the distance parameters of the joint
  61260. * @param joint joint to update
  61261. * @param maxDistance maximum distance of the joint
  61262. * @param minDistance minimum distance of the joint
  61263. */
  61264. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  61265. /**
  61266. * Sets a motor on the joint
  61267. * @param joint joint to set motor on
  61268. * @param speed speed of the motor
  61269. * @param maxForce maximum force of the motor
  61270. * @param motorIndex index of the motor
  61271. */
  61272. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  61273. /**
  61274. * Sets the motors limit
  61275. * @param joint joint to set limit on
  61276. * @param upperLimit upper limit
  61277. * @param lowerLimit lower limit
  61278. */
  61279. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  61280. /**
  61281. * Syncs the position and rotation of a mesh with the impostor
  61282. * @param mesh mesh to sync
  61283. * @param impostor impostor to update the mesh with
  61284. */
  61285. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61286. /**
  61287. * Gets the radius of the impostor
  61288. * @param impostor impostor to get radius from
  61289. * @returns the radius
  61290. */
  61291. getRadius(impostor: PhysicsImpostor): number;
  61292. /**
  61293. * Gets the box size of the impostor
  61294. * @param impostor impostor to get box size from
  61295. * @param result the resulting box size
  61296. */
  61297. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61298. /**
  61299. * Disposes of the impostor
  61300. */
  61301. dispose(): void;
  61302. /**
  61303. * Does a raycast in the physics world
  61304. * @param from when should the ray start?
  61305. * @param to when should the ray end?
  61306. * @returns PhysicsRaycastResult
  61307. */
  61308. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61309. }
  61310. }
  61311. declare module BABYLON {
  61312. interface AbstractScene {
  61313. /**
  61314. * The list of reflection probes added to the scene
  61315. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  61316. */
  61317. reflectionProbes: Array<ReflectionProbe>;
  61318. /**
  61319. * Removes the given reflection probe from this scene.
  61320. * @param toRemove The reflection probe to remove
  61321. * @returns The index of the removed reflection probe
  61322. */
  61323. removeReflectionProbe(toRemove: ReflectionProbe): number;
  61324. /**
  61325. * Adds the given reflection probe to this scene.
  61326. * @param newReflectionProbe The reflection probe to add
  61327. */
  61328. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  61329. }
  61330. /**
  61331. * Class used to generate realtime reflection / refraction cube textures
  61332. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  61333. */
  61334. export class ReflectionProbe {
  61335. /** defines the name of the probe */
  61336. name: string;
  61337. private _scene;
  61338. private _renderTargetTexture;
  61339. private _projectionMatrix;
  61340. private _viewMatrix;
  61341. private _target;
  61342. private _add;
  61343. private _attachedMesh;
  61344. private _invertYAxis;
  61345. /** Gets or sets probe position (center of the cube map) */
  61346. position: Vector3;
  61347. /**
  61348. * Creates a new reflection probe
  61349. * @param name defines the name of the probe
  61350. * @param size defines the texture resolution (for each face)
  61351. * @param scene defines the hosting scene
  61352. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  61353. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  61354. */
  61355. constructor(
  61356. /** defines the name of the probe */
  61357. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  61358. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  61359. get samples(): number;
  61360. set samples(value: number);
  61361. /** Gets or sets the refresh rate to use (on every frame by default) */
  61362. get refreshRate(): number;
  61363. set refreshRate(value: number);
  61364. /**
  61365. * Gets the hosting scene
  61366. * @returns a Scene
  61367. */
  61368. getScene(): Scene;
  61369. /** Gets the internal CubeTexture used to render to */
  61370. get cubeTexture(): RenderTargetTexture;
  61371. /** Gets the list of meshes to render */
  61372. get renderList(): Nullable<AbstractMesh[]>;
  61373. /**
  61374. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  61375. * @param mesh defines the mesh to attach to
  61376. */
  61377. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  61378. /**
  61379. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  61380. * @param renderingGroupId The rendering group id corresponding to its index
  61381. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  61382. */
  61383. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  61384. /**
  61385. * Clean all associated resources
  61386. */
  61387. dispose(): void;
  61388. /**
  61389. * Converts the reflection probe information to a readable string for debug purpose.
  61390. * @param fullDetails Supports for multiple levels of logging within scene loading
  61391. * @returns the human readable reflection probe info
  61392. */
  61393. toString(fullDetails?: boolean): string;
  61394. /**
  61395. * Get the class name of the relfection probe.
  61396. * @returns "ReflectionProbe"
  61397. */
  61398. getClassName(): string;
  61399. /**
  61400. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  61401. * @returns The JSON representation of the texture
  61402. */
  61403. serialize(): any;
  61404. /**
  61405. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  61406. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  61407. * @param scene Define the scene the parsed reflection probe should be instantiated in
  61408. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  61409. * @returns The parsed reflection probe if successful
  61410. */
  61411. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  61412. }
  61413. }
  61414. declare module BABYLON {
  61415. /** @hidden */
  61416. export var _BabylonLoaderRegistered: boolean;
  61417. /**
  61418. * Helps setting up some configuration for the babylon file loader.
  61419. */
  61420. export class BabylonFileLoaderConfiguration {
  61421. /**
  61422. * The loader does not allow injecting custom physix engine into the plugins.
  61423. * Unfortunately in ES6, we need to manually inject them into the plugin.
  61424. * So you could set this variable to your engine import to make it work.
  61425. */
  61426. static LoaderInjectedPhysicsEngine: any;
  61427. }
  61428. }
  61429. declare module BABYLON {
  61430. /**
  61431. * The Physically based simple base material of BJS.
  61432. *
  61433. * This enables better naming and convention enforcements on top of the pbrMaterial.
  61434. * It is used as the base class for both the specGloss and metalRough conventions.
  61435. */
  61436. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  61437. /**
  61438. * Number of Simultaneous lights allowed on the material.
  61439. */
  61440. maxSimultaneousLights: number;
  61441. /**
  61442. * If sets to true, disables all the lights affecting the material.
  61443. */
  61444. disableLighting: boolean;
  61445. /**
  61446. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  61447. */
  61448. environmentTexture: BaseTexture;
  61449. /**
  61450. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  61451. */
  61452. invertNormalMapX: boolean;
  61453. /**
  61454. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  61455. */
  61456. invertNormalMapY: boolean;
  61457. /**
  61458. * Normal map used in the model.
  61459. */
  61460. normalTexture: BaseTexture;
  61461. /**
  61462. * Emissivie color used to self-illuminate the model.
  61463. */
  61464. emissiveColor: Color3;
  61465. /**
  61466. * Emissivie texture used to self-illuminate the model.
  61467. */
  61468. emissiveTexture: BaseTexture;
  61469. /**
  61470. * Occlusion Channel Strenght.
  61471. */
  61472. occlusionStrength: number;
  61473. /**
  61474. * Occlusion Texture of the material (adding extra occlusion effects).
  61475. */
  61476. occlusionTexture: BaseTexture;
  61477. /**
  61478. * Defines the alpha limits in alpha test mode.
  61479. */
  61480. alphaCutOff: number;
  61481. /**
  61482. * Gets the current double sided mode.
  61483. */
  61484. get doubleSided(): boolean;
  61485. /**
  61486. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  61487. */
  61488. set doubleSided(value: boolean);
  61489. /**
  61490. * Stores the pre-calculated light information of a mesh in a texture.
  61491. */
  61492. lightmapTexture: BaseTexture;
  61493. /**
  61494. * If true, the light map contains occlusion information instead of lighting info.
  61495. */
  61496. useLightmapAsShadowmap: boolean;
  61497. /**
  61498. * Instantiates a new PBRMaterial instance.
  61499. *
  61500. * @param name The material name
  61501. * @param scene The scene the material will be use in.
  61502. */
  61503. constructor(name: string, scene: Scene);
  61504. getClassName(): string;
  61505. }
  61506. }
  61507. declare module BABYLON {
  61508. /**
  61509. * The PBR material of BJS following the metal roughness convention.
  61510. *
  61511. * This fits to the PBR convention in the GLTF definition:
  61512. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  61513. */
  61514. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  61515. /**
  61516. * The base color has two different interpretations depending on the value of metalness.
  61517. * When the material is a metal, the base color is the specific measured reflectance value
  61518. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  61519. * of the material.
  61520. */
  61521. baseColor: Color3;
  61522. /**
  61523. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  61524. * well as opacity information in the alpha channel.
  61525. */
  61526. baseTexture: BaseTexture;
  61527. /**
  61528. * Specifies the metallic scalar value of the material.
  61529. * Can also be used to scale the metalness values of the metallic texture.
  61530. */
  61531. metallic: number;
  61532. /**
  61533. * Specifies the roughness scalar value of the material.
  61534. * Can also be used to scale the roughness values of the metallic texture.
  61535. */
  61536. roughness: number;
  61537. /**
  61538. * Texture containing both the metallic value in the B channel and the
  61539. * roughness value in the G channel to keep better precision.
  61540. */
  61541. metallicRoughnessTexture: BaseTexture;
  61542. /**
  61543. * Instantiates a new PBRMetalRoughnessMaterial instance.
  61544. *
  61545. * @param name The material name
  61546. * @param scene The scene the material will be use in.
  61547. */
  61548. constructor(name: string, scene: Scene);
  61549. /**
  61550. * Return the currrent class name of the material.
  61551. */
  61552. getClassName(): string;
  61553. /**
  61554. * Makes a duplicate of the current material.
  61555. * @param name - name to use for the new material.
  61556. */
  61557. clone(name: string): PBRMetallicRoughnessMaterial;
  61558. /**
  61559. * Serialize the material to a parsable JSON object.
  61560. */
  61561. serialize(): any;
  61562. /**
  61563. * Parses a JSON object correponding to the serialize function.
  61564. */
  61565. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  61566. }
  61567. }
  61568. declare module BABYLON {
  61569. /**
  61570. * The PBR material of BJS following the specular glossiness convention.
  61571. *
  61572. * This fits to the PBR convention in the GLTF definition:
  61573. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  61574. */
  61575. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  61576. /**
  61577. * Specifies the diffuse color of the material.
  61578. */
  61579. diffuseColor: Color3;
  61580. /**
  61581. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  61582. * channel.
  61583. */
  61584. diffuseTexture: BaseTexture;
  61585. /**
  61586. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  61587. */
  61588. specularColor: Color3;
  61589. /**
  61590. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  61591. */
  61592. glossiness: number;
  61593. /**
  61594. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  61595. */
  61596. specularGlossinessTexture: BaseTexture;
  61597. /**
  61598. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  61599. *
  61600. * @param name The material name
  61601. * @param scene The scene the material will be use in.
  61602. */
  61603. constructor(name: string, scene: Scene);
  61604. /**
  61605. * Return the currrent class name of the material.
  61606. */
  61607. getClassName(): string;
  61608. /**
  61609. * Makes a duplicate of the current material.
  61610. * @param name - name to use for the new material.
  61611. */
  61612. clone(name: string): PBRSpecularGlossinessMaterial;
  61613. /**
  61614. * Serialize the material to a parsable JSON object.
  61615. */
  61616. serialize(): any;
  61617. /**
  61618. * Parses a JSON object correponding to the serialize function.
  61619. */
  61620. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  61621. }
  61622. }
  61623. declare module BABYLON {
  61624. /**
  61625. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  61626. * It can help converting any input color in a desired output one. This can then be used to create effects
  61627. * from sepia, black and white to sixties or futuristic rendering...
  61628. *
  61629. * The only supported format is currently 3dl.
  61630. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  61631. */
  61632. export class ColorGradingTexture extends BaseTexture {
  61633. /**
  61634. * The texture URL.
  61635. */
  61636. url: string;
  61637. /**
  61638. * Empty line regex stored for GC.
  61639. */
  61640. private static _noneEmptyLineRegex;
  61641. private _textureMatrix;
  61642. private _onLoad;
  61643. /**
  61644. * Instantiates a ColorGradingTexture from the following parameters.
  61645. *
  61646. * @param url The location of the color gradind data (currently only supporting 3dl)
  61647. * @param sceneOrEngine The scene or engine the texture will be used in
  61648. * @param onLoad defines a callback triggered when the texture has been loaded
  61649. */
  61650. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  61651. /**
  61652. * Fires the onload event from the constructor if requested.
  61653. */
  61654. private _triggerOnLoad;
  61655. /**
  61656. * Returns the texture matrix used in most of the material.
  61657. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  61658. */
  61659. getTextureMatrix(): Matrix;
  61660. /**
  61661. * Occurs when the file being loaded is a .3dl LUT file.
  61662. */
  61663. private load3dlTexture;
  61664. /**
  61665. * Starts the loading process of the texture.
  61666. */
  61667. private loadTexture;
  61668. /**
  61669. * Clones the color gradind texture.
  61670. */
  61671. clone(): ColorGradingTexture;
  61672. /**
  61673. * Called during delayed load for textures.
  61674. */
  61675. delayLoad(): void;
  61676. /**
  61677. * Parses a color grading texture serialized by Babylon.
  61678. * @param parsedTexture The texture information being parsedTexture
  61679. * @param scene The scene to load the texture in
  61680. * @param rootUrl The root url of the data assets to load
  61681. * @return A color gradind texture
  61682. */
  61683. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  61684. /**
  61685. * Serializes the LUT texture to json format.
  61686. */
  61687. serialize(): any;
  61688. }
  61689. }
  61690. declare module BABYLON {
  61691. /**
  61692. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  61693. */
  61694. export class EquiRectangularCubeTexture extends BaseTexture {
  61695. /** The six faces of the cube. */
  61696. private static _FacesMapping;
  61697. private _noMipmap;
  61698. private _onLoad;
  61699. private _onError;
  61700. /** The size of the cubemap. */
  61701. private _size;
  61702. /** The buffer of the image. */
  61703. private _buffer;
  61704. /** The width of the input image. */
  61705. private _width;
  61706. /** The height of the input image. */
  61707. private _height;
  61708. /** The URL to the image. */
  61709. url: string;
  61710. /**
  61711. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  61712. * @param url The location of the image
  61713. * @param scene The scene the texture will be used in
  61714. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61715. * @param noMipmap Forces to not generate the mipmap if true
  61716. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  61717. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  61718. * @param onLoad — defines a callback called when texture is loaded
  61719. * @param onError — defines a callback called if there is an error
  61720. */
  61721. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  61722. /**
  61723. * Load the image data, by putting the image on a canvas and extracting its buffer.
  61724. */
  61725. private loadImage;
  61726. /**
  61727. * Convert the image buffer into a cubemap and create a CubeTexture.
  61728. */
  61729. private loadTexture;
  61730. /**
  61731. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  61732. * @param buffer The ArrayBuffer that should be converted.
  61733. * @returns The buffer as Float32Array.
  61734. */
  61735. private getFloat32ArrayFromArrayBuffer;
  61736. /**
  61737. * Get the current class name of the texture useful for serialization or dynamic coding.
  61738. * @returns "EquiRectangularCubeTexture"
  61739. */
  61740. getClassName(): string;
  61741. /**
  61742. * Create a clone of the current EquiRectangularCubeTexture and return it.
  61743. * @returns A clone of the current EquiRectangularCubeTexture.
  61744. */
  61745. clone(): EquiRectangularCubeTexture;
  61746. }
  61747. }
  61748. declare module BABYLON {
  61749. /**
  61750. * Defines the options related to the creation of an HtmlElementTexture
  61751. */
  61752. export interface IHtmlElementTextureOptions {
  61753. /**
  61754. * Defines wether mip maps should be created or not.
  61755. */
  61756. generateMipMaps?: boolean;
  61757. /**
  61758. * Defines the sampling mode of the texture.
  61759. */
  61760. samplingMode?: number;
  61761. /**
  61762. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  61763. */
  61764. engine: Nullable<ThinEngine>;
  61765. /**
  61766. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  61767. */
  61768. scene: Nullable<Scene>;
  61769. }
  61770. /**
  61771. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  61772. * To be as efficient as possible depending on your constraints nothing aside the first upload
  61773. * is automatically managed.
  61774. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  61775. * in your application.
  61776. *
  61777. * As the update is not automatic, you need to call them manually.
  61778. */
  61779. export class HtmlElementTexture extends BaseTexture {
  61780. /**
  61781. * The texture URL.
  61782. */
  61783. element: HTMLVideoElement | HTMLCanvasElement;
  61784. private static readonly DefaultOptions;
  61785. private _textureMatrix;
  61786. private _isVideo;
  61787. private _generateMipMaps;
  61788. private _samplingMode;
  61789. /**
  61790. * Instantiates a HtmlElementTexture from the following parameters.
  61791. *
  61792. * @param name Defines the name of the texture
  61793. * @param element Defines the video or canvas the texture is filled with
  61794. * @param options Defines the other none mandatory texture creation options
  61795. */
  61796. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  61797. private _createInternalTexture;
  61798. /**
  61799. * Returns the texture matrix used in most of the material.
  61800. */
  61801. getTextureMatrix(): Matrix;
  61802. /**
  61803. * Updates the content of the texture.
  61804. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  61805. */
  61806. update(invertY?: Nullable<boolean>): void;
  61807. }
  61808. }
  61809. declare module BABYLON {
  61810. /**
  61811. * Based on jsTGALoader - Javascript loader for TGA file
  61812. * By Vincent Thibault
  61813. * @see http://blog.robrowser.com/javascript-tga-loader.html
  61814. */
  61815. export class TGATools {
  61816. private static _TYPE_INDEXED;
  61817. private static _TYPE_RGB;
  61818. private static _TYPE_GREY;
  61819. private static _TYPE_RLE_INDEXED;
  61820. private static _TYPE_RLE_RGB;
  61821. private static _TYPE_RLE_GREY;
  61822. private static _ORIGIN_MASK;
  61823. private static _ORIGIN_SHIFT;
  61824. private static _ORIGIN_BL;
  61825. private static _ORIGIN_BR;
  61826. private static _ORIGIN_UL;
  61827. private static _ORIGIN_UR;
  61828. /**
  61829. * Gets the header of a TGA file
  61830. * @param data defines the TGA data
  61831. * @returns the header
  61832. */
  61833. static GetTGAHeader(data: Uint8Array): any;
  61834. /**
  61835. * Uploads TGA content to a Babylon Texture
  61836. * @hidden
  61837. */
  61838. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  61839. /** @hidden */
  61840. 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;
  61841. /** @hidden */
  61842. 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;
  61843. /** @hidden */
  61844. 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;
  61845. /** @hidden */
  61846. 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;
  61847. /** @hidden */
  61848. 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;
  61849. /** @hidden */
  61850. 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;
  61851. }
  61852. }
  61853. declare module BABYLON {
  61854. /**
  61855. * Implementation of the TGA Texture Loader.
  61856. * @hidden
  61857. */
  61858. export class _TGATextureLoader implements IInternalTextureLoader {
  61859. /**
  61860. * Defines wether the loader supports cascade loading the different faces.
  61861. */
  61862. readonly supportCascades: boolean;
  61863. /**
  61864. * This returns if the loader support the current file information.
  61865. * @param extension defines the file extension of the file being loaded
  61866. * @returns true if the loader can load the specified file
  61867. */
  61868. canLoad(extension: string): boolean;
  61869. /**
  61870. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61871. * @param data contains the texture data
  61872. * @param texture defines the BabylonJS internal texture
  61873. * @param createPolynomials will be true if polynomials have been requested
  61874. * @param onLoad defines the callback to trigger once the texture is ready
  61875. * @param onError defines the callback to trigger in case of error
  61876. */
  61877. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61878. /**
  61879. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61880. * @param data contains the texture data
  61881. * @param texture defines the BabylonJS internal texture
  61882. * @param callback defines the method to call once ready to upload
  61883. */
  61884. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61885. }
  61886. }
  61887. declare module BABYLON {
  61888. /**
  61889. * Info about the .basis files
  61890. */
  61891. class BasisFileInfo {
  61892. /**
  61893. * If the file has alpha
  61894. */
  61895. hasAlpha: boolean;
  61896. /**
  61897. * Info about each image of the basis file
  61898. */
  61899. images: Array<{
  61900. levels: Array<{
  61901. width: number;
  61902. height: number;
  61903. transcodedPixels: ArrayBufferView;
  61904. }>;
  61905. }>;
  61906. }
  61907. /**
  61908. * Result of transcoding a basis file
  61909. */
  61910. class TranscodeResult {
  61911. /**
  61912. * Info about the .basis file
  61913. */
  61914. fileInfo: BasisFileInfo;
  61915. /**
  61916. * Format to use when loading the file
  61917. */
  61918. format: number;
  61919. }
  61920. /**
  61921. * Configuration options for the Basis transcoder
  61922. */
  61923. export class BasisTranscodeConfiguration {
  61924. /**
  61925. * Supported compression formats used to determine the supported output format of the transcoder
  61926. */
  61927. supportedCompressionFormats?: {
  61928. /**
  61929. * etc1 compression format
  61930. */
  61931. etc1?: boolean;
  61932. /**
  61933. * s3tc compression format
  61934. */
  61935. s3tc?: boolean;
  61936. /**
  61937. * pvrtc compression format
  61938. */
  61939. pvrtc?: boolean;
  61940. /**
  61941. * etc2 compression format
  61942. */
  61943. etc2?: boolean;
  61944. };
  61945. /**
  61946. * If mipmap levels should be loaded for transcoded images (Default: true)
  61947. */
  61948. loadMipmapLevels?: boolean;
  61949. /**
  61950. * Index of a single image to load (Default: all images)
  61951. */
  61952. loadSingleImage?: number;
  61953. }
  61954. /**
  61955. * Used to load .Basis files
  61956. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  61957. */
  61958. export class BasisTools {
  61959. private static _IgnoreSupportedFormats;
  61960. /**
  61961. * URL to use when loading the basis transcoder
  61962. */
  61963. static JSModuleURL: string;
  61964. /**
  61965. * URL to use when loading the wasm module for the transcoder
  61966. */
  61967. static WasmModuleURL: string;
  61968. /**
  61969. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  61970. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  61971. * @returns internal format corresponding to the Basis format
  61972. */
  61973. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  61974. private static _WorkerPromise;
  61975. private static _Worker;
  61976. private static _actionId;
  61977. private static _CreateWorkerAsync;
  61978. /**
  61979. * Transcodes a loaded image file to compressed pixel data
  61980. * @param data image data to transcode
  61981. * @param config configuration options for the transcoding
  61982. * @returns a promise resulting in the transcoded image
  61983. */
  61984. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  61985. /**
  61986. * Loads a texture from the transcode result
  61987. * @param texture texture load to
  61988. * @param transcodeResult the result of transcoding the basis file to load from
  61989. */
  61990. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  61991. }
  61992. }
  61993. declare module BABYLON {
  61994. /**
  61995. * Loader for .basis file format
  61996. */
  61997. export class _BasisTextureLoader implements IInternalTextureLoader {
  61998. /**
  61999. * Defines whether the loader supports cascade loading the different faces.
  62000. */
  62001. readonly supportCascades: boolean;
  62002. /**
  62003. * This returns if the loader support the current file information.
  62004. * @param extension defines the file extension of the file being loaded
  62005. * @returns true if the loader can load the specified file
  62006. */
  62007. canLoad(extension: string): boolean;
  62008. /**
  62009. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62010. * @param data contains the texture data
  62011. * @param texture defines the BabylonJS internal texture
  62012. * @param createPolynomials will be true if polynomials have been requested
  62013. * @param onLoad defines the callback to trigger once the texture is ready
  62014. * @param onError defines the callback to trigger in case of error
  62015. */
  62016. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62017. /**
  62018. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62019. * @param data contains the texture data
  62020. * @param texture defines the BabylonJS internal texture
  62021. * @param callback defines the method to call once ready to upload
  62022. */
  62023. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62024. }
  62025. }
  62026. declare module BABYLON {
  62027. /**
  62028. * Defines the basic options interface of a TexturePacker Frame
  62029. */
  62030. export interface ITexturePackerFrame {
  62031. /**
  62032. * The frame ID
  62033. */
  62034. id: number;
  62035. /**
  62036. * The frames Scale
  62037. */
  62038. scale: Vector2;
  62039. /**
  62040. * The Frames offset
  62041. */
  62042. offset: Vector2;
  62043. }
  62044. /**
  62045. * This is a support class for frame Data on texture packer sets.
  62046. */
  62047. export class TexturePackerFrame implements ITexturePackerFrame {
  62048. /**
  62049. * The frame ID
  62050. */
  62051. id: number;
  62052. /**
  62053. * The frames Scale
  62054. */
  62055. scale: Vector2;
  62056. /**
  62057. * The Frames offset
  62058. */
  62059. offset: Vector2;
  62060. /**
  62061. * Initializes a texture package frame.
  62062. * @param id The numerical frame identifier
  62063. * @param scale Scalar Vector2 for UV frame
  62064. * @param offset Vector2 for the frame position in UV units.
  62065. * @returns TexturePackerFrame
  62066. */
  62067. constructor(id: number, scale: Vector2, offset: Vector2);
  62068. }
  62069. }
  62070. declare module BABYLON {
  62071. /**
  62072. * Defines the basic options interface of a TexturePacker
  62073. */
  62074. export interface ITexturePackerOptions {
  62075. /**
  62076. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  62077. */
  62078. map?: string[];
  62079. /**
  62080. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  62081. */
  62082. uvsIn?: string;
  62083. /**
  62084. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  62085. */
  62086. uvsOut?: string;
  62087. /**
  62088. * number representing the layout style. Defaults to LAYOUT_STRIP
  62089. */
  62090. layout?: number;
  62091. /**
  62092. * number of columns if using custom column count layout(2). This defaults to 4.
  62093. */
  62094. colnum?: number;
  62095. /**
  62096. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  62097. */
  62098. updateInputMeshes?: boolean;
  62099. /**
  62100. * boolean flag to dispose all the source textures. Defaults to true.
  62101. */
  62102. disposeSources?: boolean;
  62103. /**
  62104. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  62105. */
  62106. fillBlanks?: boolean;
  62107. /**
  62108. * string value representing the context fill style color. Defaults to 'black'.
  62109. */
  62110. customFillColor?: string;
  62111. /**
  62112. * Width and Height Value of each Frame in the TexturePacker Sets
  62113. */
  62114. frameSize?: number;
  62115. /**
  62116. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  62117. */
  62118. paddingRatio?: number;
  62119. /**
  62120. * Number that declares the fill method for the padding gutter.
  62121. */
  62122. paddingMode?: number;
  62123. /**
  62124. * If in SUBUV_COLOR padding mode what color to use.
  62125. */
  62126. paddingColor?: Color3 | Color4;
  62127. }
  62128. /**
  62129. * Defines the basic interface of a TexturePacker JSON File
  62130. */
  62131. export interface ITexturePackerJSON {
  62132. /**
  62133. * The frame ID
  62134. */
  62135. name: string;
  62136. /**
  62137. * The base64 channel data
  62138. */
  62139. sets: any;
  62140. /**
  62141. * The options of the Packer
  62142. */
  62143. options: ITexturePackerOptions;
  62144. /**
  62145. * The frame data of the Packer
  62146. */
  62147. frames: Array<number>;
  62148. }
  62149. /**
  62150. * This is a support class that generates a series of packed texture sets.
  62151. * @see https://doc.babylonjs.com/babylon101/materials
  62152. */
  62153. export class TexturePacker {
  62154. /** Packer Layout Constant 0 */
  62155. static readonly LAYOUT_STRIP: number;
  62156. /** Packer Layout Constant 1 */
  62157. static readonly LAYOUT_POWER2: number;
  62158. /** Packer Layout Constant 2 */
  62159. static readonly LAYOUT_COLNUM: number;
  62160. /** Packer Layout Constant 0 */
  62161. static readonly SUBUV_WRAP: number;
  62162. /** Packer Layout Constant 1 */
  62163. static readonly SUBUV_EXTEND: number;
  62164. /** Packer Layout Constant 2 */
  62165. static readonly SUBUV_COLOR: number;
  62166. /** The Name of the Texture Package */
  62167. name: string;
  62168. /** The scene scope of the TexturePacker */
  62169. scene: Scene;
  62170. /** The Meshes to target */
  62171. meshes: AbstractMesh[];
  62172. /** Arguments passed with the Constructor */
  62173. options: ITexturePackerOptions;
  62174. /** The promise that is started upon initialization */
  62175. promise: Nullable<Promise<TexturePacker | string>>;
  62176. /** The Container object for the channel sets that are generated */
  62177. sets: object;
  62178. /** The Container array for the frames that are generated */
  62179. frames: TexturePackerFrame[];
  62180. /** The expected number of textures the system is parsing. */
  62181. private _expecting;
  62182. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  62183. private _paddingValue;
  62184. /**
  62185. * Initializes a texture package series from an array of meshes or a single mesh.
  62186. * @param name The name of the package
  62187. * @param meshes The target meshes to compose the package from
  62188. * @param options The arguments that texture packer should follow while building.
  62189. * @param scene The scene which the textures are scoped to.
  62190. * @returns TexturePacker
  62191. */
  62192. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  62193. /**
  62194. * Starts the package process
  62195. * @param resolve The promises resolution function
  62196. * @returns TexturePacker
  62197. */
  62198. private _createFrames;
  62199. /**
  62200. * Calculates the Size of the Channel Sets
  62201. * @returns Vector2
  62202. */
  62203. private _calculateSize;
  62204. /**
  62205. * Calculates the UV data for the frames.
  62206. * @param baseSize the base frameSize
  62207. * @param padding the base frame padding
  62208. * @param dtSize size of the Dynamic Texture for that channel
  62209. * @param dtUnits is 1/dtSize
  62210. * @param update flag to update the input meshes
  62211. */
  62212. private _calculateMeshUVFrames;
  62213. /**
  62214. * Calculates the frames Offset.
  62215. * @param index of the frame
  62216. * @returns Vector2
  62217. */
  62218. private _getFrameOffset;
  62219. /**
  62220. * Updates a Mesh to the frame data
  62221. * @param mesh that is the target
  62222. * @param frameID or the frame index
  62223. */
  62224. private _updateMeshUV;
  62225. /**
  62226. * Updates a Meshes materials to use the texture packer channels
  62227. * @param m is the mesh to target
  62228. * @param force all channels on the packer to be set.
  62229. */
  62230. private _updateTextureReferences;
  62231. /**
  62232. * Public method to set a Mesh to a frame
  62233. * @param m that is the target
  62234. * @param frameID or the frame index
  62235. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  62236. */
  62237. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  62238. /**
  62239. * Starts the async promise to compile the texture packer.
  62240. * @returns Promise<void>
  62241. */
  62242. processAsync(): Promise<void>;
  62243. /**
  62244. * Disposes all textures associated with this packer
  62245. */
  62246. dispose(): void;
  62247. /**
  62248. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  62249. * @param imageType is the image type to use.
  62250. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  62251. */
  62252. download(imageType?: string, quality?: number): void;
  62253. /**
  62254. * Public method to load a texturePacker JSON file.
  62255. * @param data of the JSON file in string format.
  62256. */
  62257. updateFromJSON(data: string): void;
  62258. }
  62259. }
  62260. declare module BABYLON {
  62261. /**
  62262. * 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.
  62263. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  62264. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  62265. */
  62266. export class CustomProceduralTexture extends ProceduralTexture {
  62267. private _animate;
  62268. private _time;
  62269. private _config;
  62270. private _texturePath;
  62271. /**
  62272. * Instantiates a new Custom Procedural Texture.
  62273. * 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.
  62274. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  62275. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  62276. * @param name Define the name of the texture
  62277. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  62278. * @param size Define the size of the texture to create
  62279. * @param scene Define the scene the texture belongs to
  62280. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  62281. * @param generateMipMaps Define if the texture should creates mip maps or not
  62282. */
  62283. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  62284. private _loadJson;
  62285. /**
  62286. * Is the texture ready to be used ? (rendered at least once)
  62287. * @returns true if ready, otherwise, false.
  62288. */
  62289. isReady(): boolean;
  62290. /**
  62291. * Render the texture to its associated render target.
  62292. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  62293. */
  62294. render(useCameraPostProcess?: boolean): void;
  62295. /**
  62296. * Update the list of dependant textures samplers in the shader.
  62297. */
  62298. updateTextures(): void;
  62299. /**
  62300. * Update the uniform values of the procedural texture in the shader.
  62301. */
  62302. updateShaderUniforms(): void;
  62303. /**
  62304. * Define if the texture animates or not.
  62305. */
  62306. get animate(): boolean;
  62307. set animate(value: boolean);
  62308. }
  62309. }
  62310. declare module BABYLON {
  62311. /** @hidden */
  62312. export var noisePixelShader: {
  62313. name: string;
  62314. shader: string;
  62315. };
  62316. }
  62317. declare module BABYLON {
  62318. /**
  62319. * Class used to generate noise procedural textures
  62320. */
  62321. export class NoiseProceduralTexture extends ProceduralTexture {
  62322. /** Gets or sets the start time (default is 0) */
  62323. time: number;
  62324. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  62325. brightness: number;
  62326. /** Defines the number of octaves to process */
  62327. octaves: number;
  62328. /** Defines the level of persistence (0.8 by default) */
  62329. persistence: number;
  62330. /** Gets or sets animation speed factor (default is 1) */
  62331. animationSpeedFactor: number;
  62332. /**
  62333. * Creates a new NoiseProceduralTexture
  62334. * @param name defines the name fo the texture
  62335. * @param size defines the size of the texture (default is 256)
  62336. * @param scene defines the hosting scene
  62337. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  62338. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  62339. */
  62340. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  62341. private _updateShaderUniforms;
  62342. protected _getDefines(): string;
  62343. /** Generate the current state of the procedural texture */
  62344. render(useCameraPostProcess?: boolean): void;
  62345. /**
  62346. * Serializes this noise procedural texture
  62347. * @returns a serialized noise procedural texture object
  62348. */
  62349. serialize(): any;
  62350. /**
  62351. * Clone the texture.
  62352. * @returns the cloned texture
  62353. */
  62354. clone(): NoiseProceduralTexture;
  62355. /**
  62356. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  62357. * @param parsedTexture defines parsed texture data
  62358. * @param scene defines the current scene
  62359. * @param rootUrl defines the root URL containing noise procedural texture information
  62360. * @returns a parsed NoiseProceduralTexture
  62361. */
  62362. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  62363. }
  62364. }
  62365. declare module BABYLON {
  62366. /**
  62367. * Raw cube texture where the raw buffers are passed in
  62368. */
  62369. export class RawCubeTexture extends CubeTexture {
  62370. /**
  62371. * Creates a cube texture where the raw buffers are passed in.
  62372. * @param scene defines the scene the texture is attached to
  62373. * @param data defines the array of data to use to create each face
  62374. * @param size defines the size of the textures
  62375. * @param format defines the format of the data
  62376. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  62377. * @param generateMipMaps defines if the engine should generate the mip levels
  62378. * @param invertY defines if data must be stored with Y axis inverted
  62379. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  62380. * @param compression defines the compression used (null by default)
  62381. */
  62382. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  62383. /**
  62384. * Updates the raw cube texture.
  62385. * @param data defines the data to store
  62386. * @param format defines the data format
  62387. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  62388. * @param invertY defines if data must be stored with Y axis inverted
  62389. * @param compression defines the compression used (null by default)
  62390. * @param level defines which level of the texture to update
  62391. */
  62392. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  62393. /**
  62394. * Updates a raw cube texture with RGBD encoded data.
  62395. * @param data defines the array of data [mipmap][face] to use to create each face
  62396. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  62397. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  62398. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  62399. * @returns a promsie that resolves when the operation is complete
  62400. */
  62401. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  62402. /**
  62403. * Clones the raw cube texture.
  62404. * @return a new cube texture
  62405. */
  62406. clone(): CubeTexture;
  62407. /** @hidden */
  62408. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  62409. }
  62410. }
  62411. declare module BABYLON {
  62412. /**
  62413. * Class used to store 2D array textures containing user data
  62414. */
  62415. export class RawTexture2DArray extends Texture {
  62416. /** Gets or sets the texture format to use */
  62417. format: number;
  62418. /**
  62419. * Create a new RawTexture2DArray
  62420. * @param data defines the data of the texture
  62421. * @param width defines the width of the texture
  62422. * @param height defines the height of the texture
  62423. * @param depth defines the number of layers of the texture
  62424. * @param format defines the texture format to use
  62425. * @param scene defines the hosting scene
  62426. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  62427. * @param invertY defines if texture must be stored with Y axis inverted
  62428. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62429. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  62430. */
  62431. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  62432. /** Gets or sets the texture format to use */
  62433. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  62434. /**
  62435. * Update the texture with new data
  62436. * @param data defines the data to store in the texture
  62437. */
  62438. update(data: ArrayBufferView): void;
  62439. }
  62440. }
  62441. declare module BABYLON {
  62442. /**
  62443. * Class used to store 3D textures containing user data
  62444. */
  62445. export class RawTexture3D extends Texture {
  62446. /** Gets or sets the texture format to use */
  62447. format: number;
  62448. /**
  62449. * Create a new RawTexture3D
  62450. * @param data defines the data of the texture
  62451. * @param width defines the width of the texture
  62452. * @param height defines the height of the texture
  62453. * @param depth defines the depth of the texture
  62454. * @param format defines the texture format to use
  62455. * @param scene defines the hosting scene
  62456. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  62457. * @param invertY defines if texture must be stored with Y axis inverted
  62458. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62459. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  62460. */
  62461. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  62462. /** Gets or sets the texture format to use */
  62463. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  62464. /**
  62465. * Update the texture with new data
  62466. * @param data defines the data to store in the texture
  62467. */
  62468. update(data: ArrayBufferView): void;
  62469. }
  62470. }
  62471. declare module BABYLON {
  62472. /**
  62473. * Creates a refraction texture used by refraction channel of the standard material.
  62474. * It is like a mirror but to see through a material.
  62475. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62476. */
  62477. export class RefractionTexture extends RenderTargetTexture {
  62478. /**
  62479. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  62480. * 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.
  62481. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62482. */
  62483. refractionPlane: Plane;
  62484. /**
  62485. * Define how deep under the surface we should see.
  62486. */
  62487. depth: number;
  62488. /**
  62489. * Creates a refraction texture used by refraction channel of the standard material.
  62490. * It is like a mirror but to see through a material.
  62491. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62492. * @param name Define the texture name
  62493. * @param size Define the size of the underlying texture
  62494. * @param scene Define the scene the refraction belongs to
  62495. * @param generateMipMaps Define if we need to generate mips level for the refraction
  62496. */
  62497. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  62498. /**
  62499. * Clone the refraction texture.
  62500. * @returns the cloned texture
  62501. */
  62502. clone(): RefractionTexture;
  62503. /**
  62504. * Serialize the texture to a JSON representation you could use in Parse later on
  62505. * @returns the serialized JSON representation
  62506. */
  62507. serialize(): any;
  62508. }
  62509. }
  62510. declare module BABYLON {
  62511. /**
  62512. * Block used to add support for vertex skinning (bones)
  62513. */
  62514. export class BonesBlock extends NodeMaterialBlock {
  62515. /**
  62516. * Creates a new BonesBlock
  62517. * @param name defines the block name
  62518. */
  62519. constructor(name: string);
  62520. /**
  62521. * Initialize the block and prepare the context for build
  62522. * @param state defines the state that will be used for the build
  62523. */
  62524. initialize(state: NodeMaterialBuildState): void;
  62525. /**
  62526. * Gets the current class name
  62527. * @returns the class name
  62528. */
  62529. getClassName(): string;
  62530. /**
  62531. * Gets the matrix indices input component
  62532. */
  62533. get matricesIndices(): NodeMaterialConnectionPoint;
  62534. /**
  62535. * Gets the matrix weights input component
  62536. */
  62537. get matricesWeights(): NodeMaterialConnectionPoint;
  62538. /**
  62539. * Gets the extra matrix indices input component
  62540. */
  62541. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  62542. /**
  62543. * Gets the extra matrix weights input component
  62544. */
  62545. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  62546. /**
  62547. * Gets the world input component
  62548. */
  62549. get world(): NodeMaterialConnectionPoint;
  62550. /**
  62551. * Gets the output component
  62552. */
  62553. get output(): NodeMaterialConnectionPoint;
  62554. autoConfigure(material: NodeMaterial): void;
  62555. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  62556. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62557. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62558. protected _buildBlock(state: NodeMaterialBuildState): this;
  62559. }
  62560. }
  62561. declare module BABYLON {
  62562. /**
  62563. * Block used to add support for instances
  62564. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  62565. */
  62566. export class InstancesBlock extends NodeMaterialBlock {
  62567. /**
  62568. * Creates a new InstancesBlock
  62569. * @param name defines the block name
  62570. */
  62571. constructor(name: string);
  62572. /**
  62573. * Gets the current class name
  62574. * @returns the class name
  62575. */
  62576. getClassName(): string;
  62577. /**
  62578. * Gets the first world row input component
  62579. */
  62580. get world0(): NodeMaterialConnectionPoint;
  62581. /**
  62582. * Gets the second world row input component
  62583. */
  62584. get world1(): NodeMaterialConnectionPoint;
  62585. /**
  62586. * Gets the third world row input component
  62587. */
  62588. get world2(): NodeMaterialConnectionPoint;
  62589. /**
  62590. * Gets the forth world row input component
  62591. */
  62592. get world3(): NodeMaterialConnectionPoint;
  62593. /**
  62594. * Gets the world input component
  62595. */
  62596. get world(): NodeMaterialConnectionPoint;
  62597. /**
  62598. * Gets the output component
  62599. */
  62600. get output(): NodeMaterialConnectionPoint;
  62601. /**
  62602. * Gets the isntanceID component
  62603. */
  62604. get instanceID(): NodeMaterialConnectionPoint;
  62605. autoConfigure(material: NodeMaterial): void;
  62606. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  62607. protected _buildBlock(state: NodeMaterialBuildState): this;
  62608. }
  62609. }
  62610. declare module BABYLON {
  62611. /**
  62612. * Block used to add morph targets support to vertex shader
  62613. */
  62614. export class MorphTargetsBlock extends NodeMaterialBlock {
  62615. private _repeatableContentAnchor;
  62616. /**
  62617. * Create a new MorphTargetsBlock
  62618. * @param name defines the block name
  62619. */
  62620. constructor(name: string);
  62621. /**
  62622. * Gets the current class name
  62623. * @returns the class name
  62624. */
  62625. getClassName(): string;
  62626. /**
  62627. * Gets the position input component
  62628. */
  62629. get position(): NodeMaterialConnectionPoint;
  62630. /**
  62631. * Gets the normal input component
  62632. */
  62633. get normal(): NodeMaterialConnectionPoint;
  62634. /**
  62635. * Gets the tangent input component
  62636. */
  62637. get tangent(): NodeMaterialConnectionPoint;
  62638. /**
  62639. * Gets the tangent input component
  62640. */
  62641. get uv(): NodeMaterialConnectionPoint;
  62642. /**
  62643. * Gets the position output component
  62644. */
  62645. get positionOutput(): NodeMaterialConnectionPoint;
  62646. /**
  62647. * Gets the normal output component
  62648. */
  62649. get normalOutput(): NodeMaterialConnectionPoint;
  62650. /**
  62651. * Gets the tangent output component
  62652. */
  62653. get tangentOutput(): NodeMaterialConnectionPoint;
  62654. /**
  62655. * Gets the tangent output component
  62656. */
  62657. get uvOutput(): NodeMaterialConnectionPoint;
  62658. initialize(state: NodeMaterialBuildState): void;
  62659. autoConfigure(material: NodeMaterial): void;
  62660. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62661. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62662. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  62663. protected _buildBlock(state: NodeMaterialBuildState): this;
  62664. }
  62665. }
  62666. declare module BABYLON {
  62667. /**
  62668. * Block used to get data information from a light
  62669. */
  62670. export class LightInformationBlock extends NodeMaterialBlock {
  62671. private _lightDataUniformName;
  62672. private _lightColorUniformName;
  62673. private _lightTypeDefineName;
  62674. /**
  62675. * Gets or sets the light associated with this block
  62676. */
  62677. light: Nullable<Light>;
  62678. /**
  62679. * Creates a new LightInformationBlock
  62680. * @param name defines the block name
  62681. */
  62682. constructor(name: string);
  62683. /**
  62684. * Gets the current class name
  62685. * @returns the class name
  62686. */
  62687. getClassName(): string;
  62688. /**
  62689. * Gets the world position input component
  62690. */
  62691. get worldPosition(): NodeMaterialConnectionPoint;
  62692. /**
  62693. * Gets the direction output component
  62694. */
  62695. get direction(): NodeMaterialConnectionPoint;
  62696. /**
  62697. * Gets the direction output component
  62698. */
  62699. get color(): NodeMaterialConnectionPoint;
  62700. /**
  62701. * Gets the direction output component
  62702. */
  62703. get intensity(): NodeMaterialConnectionPoint;
  62704. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62705. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62706. protected _buildBlock(state: NodeMaterialBuildState): this;
  62707. serialize(): any;
  62708. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62709. }
  62710. }
  62711. declare module BABYLON {
  62712. /**
  62713. * Block used to add image processing support to fragment shader
  62714. */
  62715. export class ImageProcessingBlock extends NodeMaterialBlock {
  62716. /**
  62717. * Create a new ImageProcessingBlock
  62718. * @param name defines the block name
  62719. */
  62720. constructor(name: string);
  62721. /**
  62722. * Gets the current class name
  62723. * @returns the class name
  62724. */
  62725. getClassName(): string;
  62726. /**
  62727. * Gets the color input component
  62728. */
  62729. get color(): NodeMaterialConnectionPoint;
  62730. /**
  62731. * Gets the output component
  62732. */
  62733. get output(): NodeMaterialConnectionPoint;
  62734. /**
  62735. * Initialize the block and prepare the context for build
  62736. * @param state defines the state that will be used for the build
  62737. */
  62738. initialize(state: NodeMaterialBuildState): void;
  62739. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  62740. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62741. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62742. protected _buildBlock(state: NodeMaterialBuildState): this;
  62743. }
  62744. }
  62745. declare module BABYLON {
  62746. /**
  62747. * Block used to pertub normals based on a normal map
  62748. */
  62749. export class PerturbNormalBlock extends NodeMaterialBlock {
  62750. private _tangentSpaceParameterName;
  62751. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62752. invertX: boolean;
  62753. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  62754. invertY: boolean;
  62755. /**
  62756. * Create a new PerturbNormalBlock
  62757. * @param name defines the block name
  62758. */
  62759. constructor(name: string);
  62760. /**
  62761. * Gets the current class name
  62762. * @returns the class name
  62763. */
  62764. getClassName(): string;
  62765. /**
  62766. * Gets the world position input component
  62767. */
  62768. get worldPosition(): NodeMaterialConnectionPoint;
  62769. /**
  62770. * Gets the world normal input component
  62771. */
  62772. get worldNormal(): NodeMaterialConnectionPoint;
  62773. /**
  62774. * Gets the world tangent input component
  62775. */
  62776. get worldTangent(): NodeMaterialConnectionPoint;
  62777. /**
  62778. * Gets the uv input component
  62779. */
  62780. get uv(): NodeMaterialConnectionPoint;
  62781. /**
  62782. * Gets the normal map color input component
  62783. */
  62784. get normalMapColor(): NodeMaterialConnectionPoint;
  62785. /**
  62786. * Gets the strength input component
  62787. */
  62788. get strength(): NodeMaterialConnectionPoint;
  62789. /**
  62790. * Gets the output component
  62791. */
  62792. get output(): NodeMaterialConnectionPoint;
  62793. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62794. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62795. autoConfigure(material: NodeMaterial): void;
  62796. protected _buildBlock(state: NodeMaterialBuildState): this;
  62797. protected _dumpPropertiesCode(): string;
  62798. serialize(): any;
  62799. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62800. }
  62801. }
  62802. declare module BABYLON {
  62803. /**
  62804. * Block used to discard a pixel if a value is smaller than a cutoff
  62805. */
  62806. export class DiscardBlock extends NodeMaterialBlock {
  62807. /**
  62808. * Create a new DiscardBlock
  62809. * @param name defines the block name
  62810. */
  62811. constructor(name: string);
  62812. /**
  62813. * Gets the current class name
  62814. * @returns the class name
  62815. */
  62816. getClassName(): string;
  62817. /**
  62818. * Gets the color input component
  62819. */
  62820. get value(): NodeMaterialConnectionPoint;
  62821. /**
  62822. * Gets the cutoff input component
  62823. */
  62824. get cutoff(): NodeMaterialConnectionPoint;
  62825. protected _buildBlock(state: NodeMaterialBuildState): this;
  62826. }
  62827. }
  62828. declare module BABYLON {
  62829. /**
  62830. * Block used to test if the fragment shader is front facing
  62831. */
  62832. export class FrontFacingBlock extends NodeMaterialBlock {
  62833. /**
  62834. * Creates a new FrontFacingBlock
  62835. * @param name defines the block name
  62836. */
  62837. constructor(name: string);
  62838. /**
  62839. * Gets the current class name
  62840. * @returns the class name
  62841. */
  62842. getClassName(): string;
  62843. /**
  62844. * Gets the output component
  62845. */
  62846. get output(): NodeMaterialConnectionPoint;
  62847. protected _buildBlock(state: NodeMaterialBuildState): this;
  62848. }
  62849. }
  62850. declare module BABYLON {
  62851. /**
  62852. * Block used to get the derivative value on x and y of a given input
  62853. */
  62854. export class DerivativeBlock extends NodeMaterialBlock {
  62855. /**
  62856. * Create a new DerivativeBlock
  62857. * @param name defines the block name
  62858. */
  62859. constructor(name: string);
  62860. /**
  62861. * Gets the current class name
  62862. * @returns the class name
  62863. */
  62864. getClassName(): string;
  62865. /**
  62866. * Gets the input component
  62867. */
  62868. get input(): NodeMaterialConnectionPoint;
  62869. /**
  62870. * Gets the derivative output on x
  62871. */
  62872. get dx(): NodeMaterialConnectionPoint;
  62873. /**
  62874. * Gets the derivative output on y
  62875. */
  62876. get dy(): NodeMaterialConnectionPoint;
  62877. protected _buildBlock(state: NodeMaterialBuildState): this;
  62878. }
  62879. }
  62880. declare module BABYLON {
  62881. /**
  62882. * Block used to make gl_FragCoord available
  62883. */
  62884. export class FragCoordBlock extends NodeMaterialBlock {
  62885. /**
  62886. * Creates a new FragCoordBlock
  62887. * @param name defines the block name
  62888. */
  62889. constructor(name: string);
  62890. /**
  62891. * Gets the current class name
  62892. * @returns the class name
  62893. */
  62894. getClassName(): string;
  62895. /**
  62896. * Gets the xy component
  62897. */
  62898. get xy(): NodeMaterialConnectionPoint;
  62899. /**
  62900. * Gets the xyz component
  62901. */
  62902. get xyz(): NodeMaterialConnectionPoint;
  62903. /**
  62904. * Gets the xyzw component
  62905. */
  62906. get xyzw(): NodeMaterialConnectionPoint;
  62907. /**
  62908. * Gets the x component
  62909. */
  62910. get x(): NodeMaterialConnectionPoint;
  62911. /**
  62912. * Gets the y component
  62913. */
  62914. get y(): NodeMaterialConnectionPoint;
  62915. /**
  62916. * Gets the z component
  62917. */
  62918. get z(): NodeMaterialConnectionPoint;
  62919. /**
  62920. * Gets the w component
  62921. */
  62922. get output(): NodeMaterialConnectionPoint;
  62923. protected writeOutputs(state: NodeMaterialBuildState): string;
  62924. protected _buildBlock(state: NodeMaterialBuildState): this;
  62925. }
  62926. }
  62927. declare module BABYLON {
  62928. /**
  62929. * Block used to get the screen sizes
  62930. */
  62931. export class ScreenSizeBlock extends NodeMaterialBlock {
  62932. private _varName;
  62933. private _scene;
  62934. /**
  62935. * Creates a new ScreenSizeBlock
  62936. * @param name defines the block name
  62937. */
  62938. constructor(name: string);
  62939. /**
  62940. * Gets the current class name
  62941. * @returns the class name
  62942. */
  62943. getClassName(): string;
  62944. /**
  62945. * Gets the xy component
  62946. */
  62947. get xy(): NodeMaterialConnectionPoint;
  62948. /**
  62949. * Gets the x component
  62950. */
  62951. get x(): NodeMaterialConnectionPoint;
  62952. /**
  62953. * Gets the y component
  62954. */
  62955. get y(): NodeMaterialConnectionPoint;
  62956. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62957. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  62958. protected _buildBlock(state: NodeMaterialBuildState): this;
  62959. }
  62960. }
  62961. declare module BABYLON {
  62962. /**
  62963. * Block used to add support for scene fog
  62964. */
  62965. export class FogBlock extends NodeMaterialBlock {
  62966. private _fogDistanceName;
  62967. private _fogParameters;
  62968. /**
  62969. * Create a new FogBlock
  62970. * @param name defines the block name
  62971. */
  62972. constructor(name: string);
  62973. /**
  62974. * Gets the current class name
  62975. * @returns the class name
  62976. */
  62977. getClassName(): string;
  62978. /**
  62979. * Gets the world position input component
  62980. */
  62981. get worldPosition(): NodeMaterialConnectionPoint;
  62982. /**
  62983. * Gets the view input component
  62984. */
  62985. get view(): NodeMaterialConnectionPoint;
  62986. /**
  62987. * Gets the color input component
  62988. */
  62989. get input(): NodeMaterialConnectionPoint;
  62990. /**
  62991. * Gets the fog color input component
  62992. */
  62993. get fogColor(): NodeMaterialConnectionPoint;
  62994. /**
  62995. * Gets the output component
  62996. */
  62997. get output(): NodeMaterialConnectionPoint;
  62998. autoConfigure(material: NodeMaterial): void;
  62999. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63000. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63001. protected _buildBlock(state: NodeMaterialBuildState): this;
  63002. }
  63003. }
  63004. declare module BABYLON {
  63005. /**
  63006. * Block used to add light in the fragment shader
  63007. */
  63008. export class LightBlock extends NodeMaterialBlock {
  63009. private _lightId;
  63010. /**
  63011. * Gets or sets the light associated with this block
  63012. */
  63013. light: Nullable<Light>;
  63014. /**
  63015. * Create a new LightBlock
  63016. * @param name defines the block name
  63017. */
  63018. constructor(name: string);
  63019. /**
  63020. * Gets the current class name
  63021. * @returns the class name
  63022. */
  63023. getClassName(): string;
  63024. /**
  63025. * Gets the world position input component
  63026. */
  63027. get worldPosition(): NodeMaterialConnectionPoint;
  63028. /**
  63029. * Gets the world normal input component
  63030. */
  63031. get worldNormal(): NodeMaterialConnectionPoint;
  63032. /**
  63033. * Gets the camera (or eye) position component
  63034. */
  63035. get cameraPosition(): NodeMaterialConnectionPoint;
  63036. /**
  63037. * Gets the glossiness component
  63038. */
  63039. get glossiness(): NodeMaterialConnectionPoint;
  63040. /**
  63041. * Gets the glossinness power component
  63042. */
  63043. get glossPower(): NodeMaterialConnectionPoint;
  63044. /**
  63045. * Gets the diffuse color component
  63046. */
  63047. get diffuseColor(): NodeMaterialConnectionPoint;
  63048. /**
  63049. * Gets the specular color component
  63050. */
  63051. get specularColor(): NodeMaterialConnectionPoint;
  63052. /**
  63053. * Gets the diffuse output component
  63054. */
  63055. get diffuseOutput(): NodeMaterialConnectionPoint;
  63056. /**
  63057. * Gets the specular output component
  63058. */
  63059. get specularOutput(): NodeMaterialConnectionPoint;
  63060. /**
  63061. * Gets the shadow output component
  63062. */
  63063. get shadow(): NodeMaterialConnectionPoint;
  63064. autoConfigure(material: NodeMaterial): void;
  63065. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63066. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  63067. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63068. private _injectVertexCode;
  63069. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63070. serialize(): any;
  63071. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63072. }
  63073. }
  63074. declare module BABYLON {
  63075. /**
  63076. * Block used to read a reflection texture from a sampler
  63077. */
  63078. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  63079. /**
  63080. * Create a new ReflectionTextureBlock
  63081. * @param name defines the block name
  63082. */
  63083. constructor(name: string);
  63084. /**
  63085. * Gets the current class name
  63086. * @returns the class name
  63087. */
  63088. getClassName(): string;
  63089. /**
  63090. * Gets the world position input component
  63091. */
  63092. get position(): NodeMaterialConnectionPoint;
  63093. /**
  63094. * Gets the world position input component
  63095. */
  63096. get worldPosition(): NodeMaterialConnectionPoint;
  63097. /**
  63098. * Gets the world normal input component
  63099. */
  63100. get worldNormal(): NodeMaterialConnectionPoint;
  63101. /**
  63102. * Gets the world input component
  63103. */
  63104. get world(): NodeMaterialConnectionPoint;
  63105. /**
  63106. * Gets the camera (or eye) position component
  63107. */
  63108. get cameraPosition(): NodeMaterialConnectionPoint;
  63109. /**
  63110. * Gets the view input component
  63111. */
  63112. get view(): NodeMaterialConnectionPoint;
  63113. /**
  63114. * Gets the rgb output component
  63115. */
  63116. get rgb(): NodeMaterialConnectionPoint;
  63117. /**
  63118. * Gets the rgba output component
  63119. */
  63120. get rgba(): NodeMaterialConnectionPoint;
  63121. /**
  63122. * Gets the r output component
  63123. */
  63124. get r(): NodeMaterialConnectionPoint;
  63125. /**
  63126. * Gets the g output component
  63127. */
  63128. get g(): NodeMaterialConnectionPoint;
  63129. /**
  63130. * Gets the b output component
  63131. */
  63132. get b(): NodeMaterialConnectionPoint;
  63133. /**
  63134. * Gets the a output component
  63135. */
  63136. get a(): NodeMaterialConnectionPoint;
  63137. autoConfigure(material: NodeMaterial): void;
  63138. protected _buildBlock(state: NodeMaterialBuildState): this;
  63139. }
  63140. }
  63141. declare module BABYLON {
  63142. /**
  63143. * Block used to add 2 vectors
  63144. */
  63145. export class AddBlock extends NodeMaterialBlock {
  63146. /**
  63147. * Creates a new AddBlock
  63148. * @param name defines the block name
  63149. */
  63150. constructor(name: string);
  63151. /**
  63152. * Gets the current class name
  63153. * @returns the class name
  63154. */
  63155. getClassName(): string;
  63156. /**
  63157. * Gets the left operand input component
  63158. */
  63159. get left(): NodeMaterialConnectionPoint;
  63160. /**
  63161. * Gets the right operand input component
  63162. */
  63163. get right(): NodeMaterialConnectionPoint;
  63164. /**
  63165. * Gets the output component
  63166. */
  63167. get output(): NodeMaterialConnectionPoint;
  63168. protected _buildBlock(state: NodeMaterialBuildState): this;
  63169. }
  63170. }
  63171. declare module BABYLON {
  63172. /**
  63173. * Block used to scale a vector by a float
  63174. */
  63175. export class ScaleBlock extends NodeMaterialBlock {
  63176. /**
  63177. * Creates a new ScaleBlock
  63178. * @param name defines the block name
  63179. */
  63180. constructor(name: string);
  63181. /**
  63182. * Gets the current class name
  63183. * @returns the class name
  63184. */
  63185. getClassName(): string;
  63186. /**
  63187. * Gets the input component
  63188. */
  63189. get input(): NodeMaterialConnectionPoint;
  63190. /**
  63191. * Gets the factor input component
  63192. */
  63193. get factor(): NodeMaterialConnectionPoint;
  63194. /**
  63195. * Gets the output component
  63196. */
  63197. get output(): NodeMaterialConnectionPoint;
  63198. protected _buildBlock(state: NodeMaterialBuildState): this;
  63199. }
  63200. }
  63201. declare module BABYLON {
  63202. /**
  63203. * Block used to clamp a float
  63204. */
  63205. export class ClampBlock extends NodeMaterialBlock {
  63206. /** Gets or sets the minimum range */
  63207. minimum: number;
  63208. /** Gets or sets the maximum range */
  63209. maximum: number;
  63210. /**
  63211. * Creates a new ClampBlock
  63212. * @param name defines the block name
  63213. */
  63214. constructor(name: string);
  63215. /**
  63216. * Gets the current class name
  63217. * @returns the class name
  63218. */
  63219. getClassName(): string;
  63220. /**
  63221. * Gets the value input component
  63222. */
  63223. get value(): NodeMaterialConnectionPoint;
  63224. /**
  63225. * Gets the output component
  63226. */
  63227. get output(): NodeMaterialConnectionPoint;
  63228. protected _buildBlock(state: NodeMaterialBuildState): this;
  63229. protected _dumpPropertiesCode(): string;
  63230. serialize(): any;
  63231. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63232. }
  63233. }
  63234. declare module BABYLON {
  63235. /**
  63236. * Block used to apply a cross product between 2 vectors
  63237. */
  63238. export class CrossBlock extends NodeMaterialBlock {
  63239. /**
  63240. * Creates a new CrossBlock
  63241. * @param name defines the block name
  63242. */
  63243. constructor(name: string);
  63244. /**
  63245. * Gets the current class name
  63246. * @returns the class name
  63247. */
  63248. getClassName(): string;
  63249. /**
  63250. * Gets the left operand input component
  63251. */
  63252. get left(): NodeMaterialConnectionPoint;
  63253. /**
  63254. * Gets the right operand input component
  63255. */
  63256. get right(): NodeMaterialConnectionPoint;
  63257. /**
  63258. * Gets the output component
  63259. */
  63260. get output(): NodeMaterialConnectionPoint;
  63261. protected _buildBlock(state: NodeMaterialBuildState): this;
  63262. }
  63263. }
  63264. declare module BABYLON {
  63265. /**
  63266. * Block used to apply a dot product between 2 vectors
  63267. */
  63268. export class DotBlock extends NodeMaterialBlock {
  63269. /**
  63270. * Creates a new DotBlock
  63271. * @param name defines the block name
  63272. */
  63273. constructor(name: string);
  63274. /**
  63275. * Gets the current class name
  63276. * @returns the class name
  63277. */
  63278. getClassName(): string;
  63279. /**
  63280. * Gets the left operand input component
  63281. */
  63282. get left(): NodeMaterialConnectionPoint;
  63283. /**
  63284. * Gets the right operand input component
  63285. */
  63286. get right(): NodeMaterialConnectionPoint;
  63287. /**
  63288. * Gets the output component
  63289. */
  63290. get output(): NodeMaterialConnectionPoint;
  63291. protected _buildBlock(state: NodeMaterialBuildState): this;
  63292. }
  63293. }
  63294. declare module BABYLON {
  63295. /**
  63296. * Block used to normalize a vector
  63297. */
  63298. export class NormalizeBlock extends NodeMaterialBlock {
  63299. /**
  63300. * Creates a new NormalizeBlock
  63301. * @param name defines the block name
  63302. */
  63303. constructor(name: string);
  63304. /**
  63305. * Gets the current class name
  63306. * @returns the class name
  63307. */
  63308. getClassName(): string;
  63309. /**
  63310. * Gets the input component
  63311. */
  63312. get input(): NodeMaterialConnectionPoint;
  63313. /**
  63314. * Gets the output component
  63315. */
  63316. get output(): NodeMaterialConnectionPoint;
  63317. protected _buildBlock(state: NodeMaterialBuildState): this;
  63318. }
  63319. }
  63320. declare module BABYLON {
  63321. /**
  63322. * Block used to create a Color3/4 out of individual inputs (one for each component)
  63323. */
  63324. export class ColorMergerBlock extends NodeMaterialBlock {
  63325. /**
  63326. * Create a new ColorMergerBlock
  63327. * @param name defines the block name
  63328. */
  63329. constructor(name: string);
  63330. /**
  63331. * Gets the current class name
  63332. * @returns the class name
  63333. */
  63334. getClassName(): string;
  63335. /**
  63336. * Gets the rgb component (input)
  63337. */
  63338. get rgbIn(): NodeMaterialConnectionPoint;
  63339. /**
  63340. * Gets the r component (input)
  63341. */
  63342. get r(): NodeMaterialConnectionPoint;
  63343. /**
  63344. * Gets the g component (input)
  63345. */
  63346. get g(): NodeMaterialConnectionPoint;
  63347. /**
  63348. * Gets the b component (input)
  63349. */
  63350. get b(): NodeMaterialConnectionPoint;
  63351. /**
  63352. * Gets the a component (input)
  63353. */
  63354. get a(): NodeMaterialConnectionPoint;
  63355. /**
  63356. * Gets the rgba component (output)
  63357. */
  63358. get rgba(): NodeMaterialConnectionPoint;
  63359. /**
  63360. * Gets the rgb component (output)
  63361. */
  63362. get rgbOut(): NodeMaterialConnectionPoint;
  63363. /**
  63364. * Gets the rgb component (output)
  63365. * @deprecated Please use rgbOut instead.
  63366. */
  63367. get rgb(): NodeMaterialConnectionPoint;
  63368. protected _buildBlock(state: NodeMaterialBuildState): this;
  63369. }
  63370. }
  63371. declare module BABYLON {
  63372. /**
  63373. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  63374. */
  63375. export class VectorSplitterBlock extends NodeMaterialBlock {
  63376. /**
  63377. * Create a new VectorSplitterBlock
  63378. * @param name defines the block name
  63379. */
  63380. constructor(name: string);
  63381. /**
  63382. * Gets the current class name
  63383. * @returns the class name
  63384. */
  63385. getClassName(): string;
  63386. /**
  63387. * Gets the xyzw component (input)
  63388. */
  63389. get xyzw(): NodeMaterialConnectionPoint;
  63390. /**
  63391. * Gets the xyz component (input)
  63392. */
  63393. get xyzIn(): NodeMaterialConnectionPoint;
  63394. /**
  63395. * Gets the xy component (input)
  63396. */
  63397. get xyIn(): NodeMaterialConnectionPoint;
  63398. /**
  63399. * Gets the xyz component (output)
  63400. */
  63401. get xyzOut(): NodeMaterialConnectionPoint;
  63402. /**
  63403. * Gets the xy component (output)
  63404. */
  63405. get xyOut(): NodeMaterialConnectionPoint;
  63406. /**
  63407. * Gets the x component (output)
  63408. */
  63409. get x(): NodeMaterialConnectionPoint;
  63410. /**
  63411. * Gets the y component (output)
  63412. */
  63413. get y(): NodeMaterialConnectionPoint;
  63414. /**
  63415. * Gets the z component (output)
  63416. */
  63417. get z(): NodeMaterialConnectionPoint;
  63418. /**
  63419. * Gets the w component (output)
  63420. */
  63421. get w(): NodeMaterialConnectionPoint;
  63422. protected _inputRename(name: string): string;
  63423. protected _outputRename(name: string): string;
  63424. protected _buildBlock(state: NodeMaterialBuildState): this;
  63425. }
  63426. }
  63427. declare module BABYLON {
  63428. /**
  63429. * Block used to lerp between 2 values
  63430. */
  63431. export class LerpBlock extends NodeMaterialBlock {
  63432. /**
  63433. * Creates a new LerpBlock
  63434. * @param name defines the block name
  63435. */
  63436. constructor(name: string);
  63437. /**
  63438. * Gets the current class name
  63439. * @returns the class name
  63440. */
  63441. getClassName(): string;
  63442. /**
  63443. * Gets the left operand input component
  63444. */
  63445. get left(): NodeMaterialConnectionPoint;
  63446. /**
  63447. * Gets the right operand input component
  63448. */
  63449. get right(): NodeMaterialConnectionPoint;
  63450. /**
  63451. * Gets the gradient operand input component
  63452. */
  63453. get gradient(): NodeMaterialConnectionPoint;
  63454. /**
  63455. * Gets the output component
  63456. */
  63457. get output(): NodeMaterialConnectionPoint;
  63458. protected _buildBlock(state: NodeMaterialBuildState): this;
  63459. }
  63460. }
  63461. declare module BABYLON {
  63462. /**
  63463. * Block used to divide 2 vectors
  63464. */
  63465. export class DivideBlock extends NodeMaterialBlock {
  63466. /**
  63467. * Creates a new DivideBlock
  63468. * @param name defines the block name
  63469. */
  63470. constructor(name: string);
  63471. /**
  63472. * Gets the current class name
  63473. * @returns the class name
  63474. */
  63475. getClassName(): string;
  63476. /**
  63477. * Gets the left operand input component
  63478. */
  63479. get left(): NodeMaterialConnectionPoint;
  63480. /**
  63481. * Gets the right operand input component
  63482. */
  63483. get right(): NodeMaterialConnectionPoint;
  63484. /**
  63485. * Gets the output component
  63486. */
  63487. get output(): NodeMaterialConnectionPoint;
  63488. protected _buildBlock(state: NodeMaterialBuildState): this;
  63489. }
  63490. }
  63491. declare module BABYLON {
  63492. /**
  63493. * Block used to subtract 2 vectors
  63494. */
  63495. export class SubtractBlock extends NodeMaterialBlock {
  63496. /**
  63497. * Creates a new SubtractBlock
  63498. * @param name defines the block name
  63499. */
  63500. constructor(name: string);
  63501. /**
  63502. * Gets the current class name
  63503. * @returns the class name
  63504. */
  63505. getClassName(): string;
  63506. /**
  63507. * Gets the left operand input component
  63508. */
  63509. get left(): NodeMaterialConnectionPoint;
  63510. /**
  63511. * Gets the right operand input component
  63512. */
  63513. get right(): NodeMaterialConnectionPoint;
  63514. /**
  63515. * Gets the output component
  63516. */
  63517. get output(): NodeMaterialConnectionPoint;
  63518. protected _buildBlock(state: NodeMaterialBuildState): this;
  63519. }
  63520. }
  63521. declare module BABYLON {
  63522. /**
  63523. * Block used to step a value
  63524. */
  63525. export class StepBlock extends NodeMaterialBlock {
  63526. /**
  63527. * Creates a new StepBlock
  63528. * @param name defines the block name
  63529. */
  63530. constructor(name: string);
  63531. /**
  63532. * Gets the current class name
  63533. * @returns the class name
  63534. */
  63535. getClassName(): string;
  63536. /**
  63537. * Gets the value operand input component
  63538. */
  63539. get value(): NodeMaterialConnectionPoint;
  63540. /**
  63541. * Gets the edge operand input component
  63542. */
  63543. get edge(): NodeMaterialConnectionPoint;
  63544. /**
  63545. * Gets the output component
  63546. */
  63547. get output(): NodeMaterialConnectionPoint;
  63548. protected _buildBlock(state: NodeMaterialBuildState): this;
  63549. }
  63550. }
  63551. declare module BABYLON {
  63552. /**
  63553. * Block used to get the opposite (1 - x) of a value
  63554. */
  63555. export class OneMinusBlock extends NodeMaterialBlock {
  63556. /**
  63557. * Creates a new OneMinusBlock
  63558. * @param name defines the block name
  63559. */
  63560. constructor(name: string);
  63561. /**
  63562. * Gets the current class name
  63563. * @returns the class name
  63564. */
  63565. getClassName(): string;
  63566. /**
  63567. * Gets the input component
  63568. */
  63569. get input(): NodeMaterialConnectionPoint;
  63570. /**
  63571. * Gets the output component
  63572. */
  63573. get output(): NodeMaterialConnectionPoint;
  63574. protected _buildBlock(state: NodeMaterialBuildState): this;
  63575. }
  63576. }
  63577. declare module BABYLON {
  63578. /**
  63579. * Block used to get the view direction
  63580. */
  63581. export class ViewDirectionBlock extends NodeMaterialBlock {
  63582. /**
  63583. * Creates a new ViewDirectionBlock
  63584. * @param name defines the block name
  63585. */
  63586. constructor(name: string);
  63587. /**
  63588. * Gets the current class name
  63589. * @returns the class name
  63590. */
  63591. getClassName(): string;
  63592. /**
  63593. * Gets the world position component
  63594. */
  63595. get worldPosition(): NodeMaterialConnectionPoint;
  63596. /**
  63597. * Gets the camera position component
  63598. */
  63599. get cameraPosition(): NodeMaterialConnectionPoint;
  63600. /**
  63601. * Gets the output component
  63602. */
  63603. get output(): NodeMaterialConnectionPoint;
  63604. autoConfigure(material: NodeMaterial): void;
  63605. protected _buildBlock(state: NodeMaterialBuildState): this;
  63606. }
  63607. }
  63608. declare module BABYLON {
  63609. /**
  63610. * Block used to compute fresnel value
  63611. */
  63612. export class FresnelBlock extends NodeMaterialBlock {
  63613. /**
  63614. * Create a new FresnelBlock
  63615. * @param name defines the block name
  63616. */
  63617. constructor(name: string);
  63618. /**
  63619. * Gets the current class name
  63620. * @returns the class name
  63621. */
  63622. getClassName(): string;
  63623. /**
  63624. * Gets the world normal input component
  63625. */
  63626. get worldNormal(): NodeMaterialConnectionPoint;
  63627. /**
  63628. * Gets the view direction input component
  63629. */
  63630. get viewDirection(): NodeMaterialConnectionPoint;
  63631. /**
  63632. * Gets the bias input component
  63633. */
  63634. get bias(): NodeMaterialConnectionPoint;
  63635. /**
  63636. * Gets the camera (or eye) position component
  63637. */
  63638. get power(): NodeMaterialConnectionPoint;
  63639. /**
  63640. * Gets the fresnel output component
  63641. */
  63642. get fresnel(): NodeMaterialConnectionPoint;
  63643. autoConfigure(material: NodeMaterial): void;
  63644. protected _buildBlock(state: NodeMaterialBuildState): this;
  63645. }
  63646. }
  63647. declare module BABYLON {
  63648. /**
  63649. * Block used to get the max of 2 values
  63650. */
  63651. export class MaxBlock extends NodeMaterialBlock {
  63652. /**
  63653. * Creates a new MaxBlock
  63654. * @param name defines the block name
  63655. */
  63656. constructor(name: string);
  63657. /**
  63658. * Gets the current class name
  63659. * @returns the class name
  63660. */
  63661. getClassName(): string;
  63662. /**
  63663. * Gets the left operand input component
  63664. */
  63665. get left(): NodeMaterialConnectionPoint;
  63666. /**
  63667. * Gets the right operand input component
  63668. */
  63669. get right(): NodeMaterialConnectionPoint;
  63670. /**
  63671. * Gets the output component
  63672. */
  63673. get output(): NodeMaterialConnectionPoint;
  63674. protected _buildBlock(state: NodeMaterialBuildState): this;
  63675. }
  63676. }
  63677. declare module BABYLON {
  63678. /**
  63679. * Block used to get the min of 2 values
  63680. */
  63681. export class MinBlock extends NodeMaterialBlock {
  63682. /**
  63683. * Creates a new MinBlock
  63684. * @param name defines the block name
  63685. */
  63686. constructor(name: string);
  63687. /**
  63688. * Gets the current class name
  63689. * @returns the class name
  63690. */
  63691. getClassName(): string;
  63692. /**
  63693. * Gets the left operand input component
  63694. */
  63695. get left(): NodeMaterialConnectionPoint;
  63696. /**
  63697. * Gets the right operand input component
  63698. */
  63699. get right(): NodeMaterialConnectionPoint;
  63700. /**
  63701. * Gets the output component
  63702. */
  63703. get output(): NodeMaterialConnectionPoint;
  63704. protected _buildBlock(state: NodeMaterialBuildState): this;
  63705. }
  63706. }
  63707. declare module BABYLON {
  63708. /**
  63709. * Block used to get the distance between 2 values
  63710. */
  63711. export class DistanceBlock extends NodeMaterialBlock {
  63712. /**
  63713. * Creates a new DistanceBlock
  63714. * @param name defines the block name
  63715. */
  63716. constructor(name: string);
  63717. /**
  63718. * Gets the current class name
  63719. * @returns the class name
  63720. */
  63721. getClassName(): string;
  63722. /**
  63723. * Gets the left operand input component
  63724. */
  63725. get left(): NodeMaterialConnectionPoint;
  63726. /**
  63727. * Gets the right operand input component
  63728. */
  63729. get right(): NodeMaterialConnectionPoint;
  63730. /**
  63731. * Gets the output component
  63732. */
  63733. get output(): NodeMaterialConnectionPoint;
  63734. protected _buildBlock(state: NodeMaterialBuildState): this;
  63735. }
  63736. }
  63737. declare module BABYLON {
  63738. /**
  63739. * Block used to get the length of a vector
  63740. */
  63741. export class LengthBlock extends NodeMaterialBlock {
  63742. /**
  63743. * Creates a new LengthBlock
  63744. * @param name defines the block name
  63745. */
  63746. constructor(name: string);
  63747. /**
  63748. * Gets the current class name
  63749. * @returns the class name
  63750. */
  63751. getClassName(): string;
  63752. /**
  63753. * Gets the value input component
  63754. */
  63755. get value(): NodeMaterialConnectionPoint;
  63756. /**
  63757. * Gets the output component
  63758. */
  63759. get output(): NodeMaterialConnectionPoint;
  63760. protected _buildBlock(state: NodeMaterialBuildState): this;
  63761. }
  63762. }
  63763. declare module BABYLON {
  63764. /**
  63765. * Block used to get negative version of a value (i.e. x * -1)
  63766. */
  63767. export class NegateBlock extends NodeMaterialBlock {
  63768. /**
  63769. * Creates a new NegateBlock
  63770. * @param name defines the block name
  63771. */
  63772. constructor(name: string);
  63773. /**
  63774. * Gets the current class name
  63775. * @returns the class name
  63776. */
  63777. getClassName(): string;
  63778. /**
  63779. * Gets the value input component
  63780. */
  63781. get value(): NodeMaterialConnectionPoint;
  63782. /**
  63783. * Gets the output component
  63784. */
  63785. get output(): NodeMaterialConnectionPoint;
  63786. protected _buildBlock(state: NodeMaterialBuildState): this;
  63787. }
  63788. }
  63789. declare module BABYLON {
  63790. /**
  63791. * Block used to get the value of the first parameter raised to the power of the second
  63792. */
  63793. export class PowBlock extends NodeMaterialBlock {
  63794. /**
  63795. * Creates a new PowBlock
  63796. * @param name defines the block name
  63797. */
  63798. constructor(name: string);
  63799. /**
  63800. * Gets the current class name
  63801. * @returns the class name
  63802. */
  63803. getClassName(): string;
  63804. /**
  63805. * Gets the value operand input component
  63806. */
  63807. get value(): NodeMaterialConnectionPoint;
  63808. /**
  63809. * Gets the power operand input component
  63810. */
  63811. get power(): NodeMaterialConnectionPoint;
  63812. /**
  63813. * Gets the output component
  63814. */
  63815. get output(): NodeMaterialConnectionPoint;
  63816. protected _buildBlock(state: NodeMaterialBuildState): this;
  63817. }
  63818. }
  63819. declare module BABYLON {
  63820. /**
  63821. * Block used to get a random number
  63822. */
  63823. export class RandomNumberBlock extends NodeMaterialBlock {
  63824. /**
  63825. * Creates a new RandomNumberBlock
  63826. * @param name defines the block name
  63827. */
  63828. constructor(name: string);
  63829. /**
  63830. * Gets the current class name
  63831. * @returns the class name
  63832. */
  63833. getClassName(): string;
  63834. /**
  63835. * Gets the seed input component
  63836. */
  63837. get seed(): NodeMaterialConnectionPoint;
  63838. /**
  63839. * Gets the output component
  63840. */
  63841. get output(): NodeMaterialConnectionPoint;
  63842. protected _buildBlock(state: NodeMaterialBuildState): this;
  63843. }
  63844. }
  63845. declare module BABYLON {
  63846. /**
  63847. * Block used to compute arc tangent of 2 values
  63848. */
  63849. export class ArcTan2Block extends NodeMaterialBlock {
  63850. /**
  63851. * Creates a new ArcTan2Block
  63852. * @param name defines the block name
  63853. */
  63854. constructor(name: string);
  63855. /**
  63856. * Gets the current class name
  63857. * @returns the class name
  63858. */
  63859. getClassName(): string;
  63860. /**
  63861. * Gets the x operand input component
  63862. */
  63863. get x(): NodeMaterialConnectionPoint;
  63864. /**
  63865. * Gets the y operand input component
  63866. */
  63867. get y(): NodeMaterialConnectionPoint;
  63868. /**
  63869. * Gets the output component
  63870. */
  63871. get output(): NodeMaterialConnectionPoint;
  63872. protected _buildBlock(state: NodeMaterialBuildState): this;
  63873. }
  63874. }
  63875. declare module BABYLON {
  63876. /**
  63877. * Block used to smooth step a value
  63878. */
  63879. export class SmoothStepBlock extends NodeMaterialBlock {
  63880. /**
  63881. * Creates a new SmoothStepBlock
  63882. * @param name defines the block name
  63883. */
  63884. constructor(name: string);
  63885. /**
  63886. * Gets the current class name
  63887. * @returns the class name
  63888. */
  63889. getClassName(): string;
  63890. /**
  63891. * Gets the value operand input component
  63892. */
  63893. get value(): NodeMaterialConnectionPoint;
  63894. /**
  63895. * Gets the first edge operand input component
  63896. */
  63897. get edge0(): NodeMaterialConnectionPoint;
  63898. /**
  63899. * Gets the second edge operand input component
  63900. */
  63901. get edge1(): NodeMaterialConnectionPoint;
  63902. /**
  63903. * Gets the output component
  63904. */
  63905. get output(): NodeMaterialConnectionPoint;
  63906. protected _buildBlock(state: NodeMaterialBuildState): this;
  63907. }
  63908. }
  63909. declare module BABYLON {
  63910. /**
  63911. * Block used to get the reciprocal (1 / x) of a value
  63912. */
  63913. export class ReciprocalBlock extends NodeMaterialBlock {
  63914. /**
  63915. * Creates a new ReciprocalBlock
  63916. * @param name defines the block name
  63917. */
  63918. constructor(name: string);
  63919. /**
  63920. * Gets the current class name
  63921. * @returns the class name
  63922. */
  63923. getClassName(): string;
  63924. /**
  63925. * Gets the input component
  63926. */
  63927. get input(): NodeMaterialConnectionPoint;
  63928. /**
  63929. * Gets the output component
  63930. */
  63931. get output(): NodeMaterialConnectionPoint;
  63932. protected _buildBlock(state: NodeMaterialBuildState): this;
  63933. }
  63934. }
  63935. declare module BABYLON {
  63936. /**
  63937. * Block used to replace a color by another one
  63938. */
  63939. export class ReplaceColorBlock extends NodeMaterialBlock {
  63940. /**
  63941. * Creates a new ReplaceColorBlock
  63942. * @param name defines the block name
  63943. */
  63944. constructor(name: string);
  63945. /**
  63946. * Gets the current class name
  63947. * @returns the class name
  63948. */
  63949. getClassName(): string;
  63950. /**
  63951. * Gets the value input component
  63952. */
  63953. get value(): NodeMaterialConnectionPoint;
  63954. /**
  63955. * Gets the reference input component
  63956. */
  63957. get reference(): NodeMaterialConnectionPoint;
  63958. /**
  63959. * Gets the distance input component
  63960. */
  63961. get distance(): NodeMaterialConnectionPoint;
  63962. /**
  63963. * Gets the replacement input component
  63964. */
  63965. get replacement(): NodeMaterialConnectionPoint;
  63966. /**
  63967. * Gets the output component
  63968. */
  63969. get output(): NodeMaterialConnectionPoint;
  63970. protected _buildBlock(state: NodeMaterialBuildState): this;
  63971. }
  63972. }
  63973. declare module BABYLON {
  63974. /**
  63975. * Block used to posterize a value
  63976. * @see https://en.wikipedia.org/wiki/Posterization
  63977. */
  63978. export class PosterizeBlock extends NodeMaterialBlock {
  63979. /**
  63980. * Creates a new PosterizeBlock
  63981. * @param name defines the block name
  63982. */
  63983. constructor(name: string);
  63984. /**
  63985. * Gets the current class name
  63986. * @returns the class name
  63987. */
  63988. getClassName(): string;
  63989. /**
  63990. * Gets the value input component
  63991. */
  63992. get value(): NodeMaterialConnectionPoint;
  63993. /**
  63994. * Gets the steps input component
  63995. */
  63996. get steps(): NodeMaterialConnectionPoint;
  63997. /**
  63998. * Gets the output component
  63999. */
  64000. get output(): NodeMaterialConnectionPoint;
  64001. protected _buildBlock(state: NodeMaterialBuildState): this;
  64002. }
  64003. }
  64004. declare module BABYLON {
  64005. /**
  64006. * Operations supported by the Wave block
  64007. */
  64008. export enum WaveBlockKind {
  64009. /** SawTooth */
  64010. SawTooth = 0,
  64011. /** Square */
  64012. Square = 1,
  64013. /** Triangle */
  64014. Triangle = 2
  64015. }
  64016. /**
  64017. * Block used to apply wave operation to floats
  64018. */
  64019. export class WaveBlock extends NodeMaterialBlock {
  64020. /**
  64021. * Gets or sets the kibnd of wave to be applied by the block
  64022. */
  64023. kind: WaveBlockKind;
  64024. /**
  64025. * Creates a new WaveBlock
  64026. * @param name defines the block name
  64027. */
  64028. constructor(name: string);
  64029. /**
  64030. * Gets the current class name
  64031. * @returns the class name
  64032. */
  64033. getClassName(): string;
  64034. /**
  64035. * Gets the input component
  64036. */
  64037. get input(): NodeMaterialConnectionPoint;
  64038. /**
  64039. * Gets the output component
  64040. */
  64041. get output(): NodeMaterialConnectionPoint;
  64042. protected _buildBlock(state: NodeMaterialBuildState): this;
  64043. serialize(): any;
  64044. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64045. }
  64046. }
  64047. declare module BABYLON {
  64048. /**
  64049. * Class used to store a color step for the GradientBlock
  64050. */
  64051. export class GradientBlockColorStep {
  64052. private _step;
  64053. /**
  64054. * Gets value indicating which step this color is associated with (between 0 and 1)
  64055. */
  64056. get step(): number;
  64057. /**
  64058. * Sets a value indicating which step this color is associated with (between 0 and 1)
  64059. */
  64060. set step(val: number);
  64061. private _color;
  64062. /**
  64063. * Gets the color associated with this step
  64064. */
  64065. get color(): Color3;
  64066. /**
  64067. * Sets the color associated with this step
  64068. */
  64069. set color(val: Color3);
  64070. /**
  64071. * Creates a new GradientBlockColorStep
  64072. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  64073. * @param color defines the color associated with this step
  64074. */
  64075. constructor(step: number, color: Color3);
  64076. }
  64077. /**
  64078. * Block used to return a color from a gradient based on an input value between 0 and 1
  64079. */
  64080. export class GradientBlock extends NodeMaterialBlock {
  64081. /**
  64082. * Gets or sets the list of color steps
  64083. */
  64084. colorSteps: GradientBlockColorStep[];
  64085. /** Gets an observable raised when the value is changed */
  64086. onValueChangedObservable: Observable<GradientBlock>;
  64087. /** calls observable when the value is changed*/
  64088. colorStepsUpdated(): void;
  64089. /**
  64090. * Creates a new GradientBlock
  64091. * @param name defines the block name
  64092. */
  64093. constructor(name: string);
  64094. /**
  64095. * Gets the current class name
  64096. * @returns the class name
  64097. */
  64098. getClassName(): string;
  64099. /**
  64100. * Gets the gradient input component
  64101. */
  64102. get gradient(): NodeMaterialConnectionPoint;
  64103. /**
  64104. * Gets the output component
  64105. */
  64106. get output(): NodeMaterialConnectionPoint;
  64107. private _writeColorConstant;
  64108. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64109. serialize(): any;
  64110. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64111. protected _dumpPropertiesCode(): string;
  64112. }
  64113. }
  64114. declare module BABYLON {
  64115. /**
  64116. * Block used to normalize lerp between 2 values
  64117. */
  64118. export class NLerpBlock extends NodeMaterialBlock {
  64119. /**
  64120. * Creates a new NLerpBlock
  64121. * @param name defines the block name
  64122. */
  64123. constructor(name: string);
  64124. /**
  64125. * Gets the current class name
  64126. * @returns the class name
  64127. */
  64128. getClassName(): string;
  64129. /**
  64130. * Gets the left operand input component
  64131. */
  64132. get left(): NodeMaterialConnectionPoint;
  64133. /**
  64134. * Gets the right operand input component
  64135. */
  64136. get right(): NodeMaterialConnectionPoint;
  64137. /**
  64138. * Gets the gradient operand input component
  64139. */
  64140. get gradient(): NodeMaterialConnectionPoint;
  64141. /**
  64142. * Gets the output component
  64143. */
  64144. get output(): NodeMaterialConnectionPoint;
  64145. protected _buildBlock(state: NodeMaterialBuildState): this;
  64146. }
  64147. }
  64148. declare module BABYLON {
  64149. /**
  64150. * block used to Generate a Worley Noise 3D Noise Pattern
  64151. */
  64152. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  64153. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  64154. manhattanDistance: boolean;
  64155. /**
  64156. * Creates a new WorleyNoise3DBlock
  64157. * @param name defines the block name
  64158. */
  64159. constructor(name: string);
  64160. /**
  64161. * Gets the current class name
  64162. * @returns the class name
  64163. */
  64164. getClassName(): string;
  64165. /**
  64166. * Gets the seed input component
  64167. */
  64168. get seed(): NodeMaterialConnectionPoint;
  64169. /**
  64170. * Gets the jitter input component
  64171. */
  64172. get jitter(): NodeMaterialConnectionPoint;
  64173. /**
  64174. * Gets the output component
  64175. */
  64176. get output(): NodeMaterialConnectionPoint;
  64177. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64178. /**
  64179. * Exposes the properties to the UI?
  64180. */
  64181. protected _dumpPropertiesCode(): string;
  64182. /**
  64183. * Exposes the properties to the Seralize?
  64184. */
  64185. serialize(): any;
  64186. /**
  64187. * Exposes the properties to the deseralize?
  64188. */
  64189. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64190. }
  64191. }
  64192. declare module BABYLON {
  64193. /**
  64194. * block used to Generate a Simplex Perlin 3d Noise Pattern
  64195. */
  64196. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  64197. /**
  64198. * Creates a new SimplexPerlin3DBlock
  64199. * @param name defines the block name
  64200. */
  64201. constructor(name: string);
  64202. /**
  64203. * Gets the current class name
  64204. * @returns the class name
  64205. */
  64206. getClassName(): string;
  64207. /**
  64208. * Gets the seed operand input component
  64209. */
  64210. get seed(): NodeMaterialConnectionPoint;
  64211. /**
  64212. * Gets the output component
  64213. */
  64214. get output(): NodeMaterialConnectionPoint;
  64215. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64216. }
  64217. }
  64218. declare module BABYLON {
  64219. /**
  64220. * Block used to blend normals
  64221. */
  64222. export class NormalBlendBlock extends NodeMaterialBlock {
  64223. /**
  64224. * Creates a new NormalBlendBlock
  64225. * @param name defines the block name
  64226. */
  64227. constructor(name: string);
  64228. /**
  64229. * Gets the current class name
  64230. * @returns the class name
  64231. */
  64232. getClassName(): string;
  64233. /**
  64234. * Gets the first input component
  64235. */
  64236. get normalMap0(): NodeMaterialConnectionPoint;
  64237. /**
  64238. * Gets the second input component
  64239. */
  64240. get normalMap1(): NodeMaterialConnectionPoint;
  64241. /**
  64242. * Gets the output component
  64243. */
  64244. get output(): NodeMaterialConnectionPoint;
  64245. protected _buildBlock(state: NodeMaterialBuildState): this;
  64246. }
  64247. }
  64248. declare module BABYLON {
  64249. /**
  64250. * Block used to rotate a 2d vector by a given angle
  64251. */
  64252. export class Rotate2dBlock extends NodeMaterialBlock {
  64253. /**
  64254. * Creates a new Rotate2dBlock
  64255. * @param name defines the block name
  64256. */
  64257. constructor(name: string);
  64258. /**
  64259. * Gets the current class name
  64260. * @returns the class name
  64261. */
  64262. getClassName(): string;
  64263. /**
  64264. * Gets the input vector
  64265. */
  64266. get input(): NodeMaterialConnectionPoint;
  64267. /**
  64268. * Gets the input angle
  64269. */
  64270. get angle(): NodeMaterialConnectionPoint;
  64271. /**
  64272. * Gets the output component
  64273. */
  64274. get output(): NodeMaterialConnectionPoint;
  64275. autoConfigure(material: NodeMaterial): void;
  64276. protected _buildBlock(state: NodeMaterialBuildState): this;
  64277. }
  64278. }
  64279. declare module BABYLON {
  64280. /**
  64281. * Block used to get the reflected vector from a direction and a normal
  64282. */
  64283. export class ReflectBlock extends NodeMaterialBlock {
  64284. /**
  64285. * Creates a new ReflectBlock
  64286. * @param name defines the block name
  64287. */
  64288. constructor(name: string);
  64289. /**
  64290. * Gets the current class name
  64291. * @returns the class name
  64292. */
  64293. getClassName(): string;
  64294. /**
  64295. * Gets the incident component
  64296. */
  64297. get incident(): NodeMaterialConnectionPoint;
  64298. /**
  64299. * Gets the normal component
  64300. */
  64301. get normal(): NodeMaterialConnectionPoint;
  64302. /**
  64303. * Gets the output component
  64304. */
  64305. get output(): NodeMaterialConnectionPoint;
  64306. protected _buildBlock(state: NodeMaterialBuildState): this;
  64307. }
  64308. }
  64309. declare module BABYLON {
  64310. /**
  64311. * Block used to get the refracted vector from a direction and a normal
  64312. */
  64313. export class RefractBlock extends NodeMaterialBlock {
  64314. /**
  64315. * Creates a new RefractBlock
  64316. * @param name defines the block name
  64317. */
  64318. constructor(name: string);
  64319. /**
  64320. * Gets the current class name
  64321. * @returns the class name
  64322. */
  64323. getClassName(): string;
  64324. /**
  64325. * Gets the incident component
  64326. */
  64327. get incident(): NodeMaterialConnectionPoint;
  64328. /**
  64329. * Gets the normal component
  64330. */
  64331. get normal(): NodeMaterialConnectionPoint;
  64332. /**
  64333. * Gets the index of refraction component
  64334. */
  64335. get ior(): NodeMaterialConnectionPoint;
  64336. /**
  64337. * Gets the output component
  64338. */
  64339. get output(): NodeMaterialConnectionPoint;
  64340. protected _buildBlock(state: NodeMaterialBuildState): this;
  64341. }
  64342. }
  64343. declare module BABYLON {
  64344. /**
  64345. * Block used to desaturate a color
  64346. */
  64347. export class DesaturateBlock extends NodeMaterialBlock {
  64348. /**
  64349. * Creates a new DesaturateBlock
  64350. * @param name defines the block name
  64351. */
  64352. constructor(name: string);
  64353. /**
  64354. * Gets the current class name
  64355. * @returns the class name
  64356. */
  64357. getClassName(): string;
  64358. /**
  64359. * Gets the color operand input component
  64360. */
  64361. get color(): NodeMaterialConnectionPoint;
  64362. /**
  64363. * Gets the level operand input component
  64364. */
  64365. get level(): NodeMaterialConnectionPoint;
  64366. /**
  64367. * Gets the output component
  64368. */
  64369. get output(): NodeMaterialConnectionPoint;
  64370. protected _buildBlock(state: NodeMaterialBuildState): this;
  64371. }
  64372. }
  64373. declare module BABYLON {
  64374. /**
  64375. * Block used to implement the ambient occlusion module of the PBR material
  64376. */
  64377. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  64378. /**
  64379. * Create a new AmbientOcclusionBlock
  64380. * @param name defines the block name
  64381. */
  64382. constructor(name: string);
  64383. /**
  64384. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  64385. */
  64386. useAmbientInGrayScale: boolean;
  64387. /**
  64388. * Initialize the block and prepare the context for build
  64389. * @param state defines the state that will be used for the build
  64390. */
  64391. initialize(state: NodeMaterialBuildState): void;
  64392. /**
  64393. * Gets the current class name
  64394. * @returns the class name
  64395. */
  64396. getClassName(): string;
  64397. /**
  64398. * Gets the texture input component
  64399. */
  64400. get texture(): NodeMaterialConnectionPoint;
  64401. /**
  64402. * Gets the texture intensity component
  64403. */
  64404. get intensity(): NodeMaterialConnectionPoint;
  64405. /**
  64406. * Gets the direct light intensity input component
  64407. */
  64408. get directLightIntensity(): NodeMaterialConnectionPoint;
  64409. /**
  64410. * Gets the ambient occlusion object output component
  64411. */
  64412. get ambientOcclusion(): NodeMaterialConnectionPoint;
  64413. /**
  64414. * Gets the main code of the block (fragment side)
  64415. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  64416. * @returns the shader code
  64417. */
  64418. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  64419. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64420. protected _buildBlock(state: NodeMaterialBuildState): this;
  64421. protected _dumpPropertiesCode(): string;
  64422. serialize(): any;
  64423. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64424. }
  64425. }
  64426. declare module BABYLON {
  64427. /**
  64428. * Block used to implement the reflection module of the PBR material
  64429. */
  64430. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  64431. /** @hidden */
  64432. _defineLODReflectionAlpha: string;
  64433. /** @hidden */
  64434. _defineLinearSpecularReflection: string;
  64435. private _vEnvironmentIrradianceName;
  64436. /** @hidden */
  64437. _vReflectionMicrosurfaceInfosName: string;
  64438. /** @hidden */
  64439. _vReflectionInfosName: string;
  64440. /** @hidden */
  64441. _vReflectionFilteringInfoName: string;
  64442. private _scene;
  64443. /**
  64444. * The three properties below are set by the main PBR block prior to calling methods of this class.
  64445. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64446. * It's less burden on the user side in the editor part.
  64447. */
  64448. /** @hidden */
  64449. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64450. /** @hidden */
  64451. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64452. /** @hidden */
  64453. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  64454. /**
  64455. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  64456. * diffuse part of the IBL.
  64457. */
  64458. useSphericalHarmonics: boolean;
  64459. /**
  64460. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  64461. */
  64462. forceIrradianceInFragment: boolean;
  64463. /**
  64464. * Create a new ReflectionBlock
  64465. * @param name defines the block name
  64466. */
  64467. constructor(name: string);
  64468. /**
  64469. * Gets the current class name
  64470. * @returns the class name
  64471. */
  64472. getClassName(): string;
  64473. /**
  64474. * Gets the position input component
  64475. */
  64476. get position(): NodeMaterialConnectionPoint;
  64477. /**
  64478. * Gets the world position input component
  64479. */
  64480. get worldPosition(): NodeMaterialConnectionPoint;
  64481. /**
  64482. * Gets the world normal input component
  64483. */
  64484. get worldNormal(): NodeMaterialConnectionPoint;
  64485. /**
  64486. * Gets the world input component
  64487. */
  64488. get world(): NodeMaterialConnectionPoint;
  64489. /**
  64490. * Gets the camera (or eye) position component
  64491. */
  64492. get cameraPosition(): NodeMaterialConnectionPoint;
  64493. /**
  64494. * Gets the view input component
  64495. */
  64496. get view(): NodeMaterialConnectionPoint;
  64497. /**
  64498. * Gets the color input component
  64499. */
  64500. get color(): NodeMaterialConnectionPoint;
  64501. /**
  64502. * Gets the reflection object output component
  64503. */
  64504. get reflection(): NodeMaterialConnectionPoint;
  64505. /**
  64506. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  64507. */
  64508. get hasTexture(): boolean;
  64509. /**
  64510. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  64511. */
  64512. get reflectionColor(): string;
  64513. protected _getTexture(): Nullable<BaseTexture>;
  64514. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64515. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64516. /**
  64517. * Gets the code to inject in the vertex shader
  64518. * @param state current state of the node material building
  64519. * @returns the shader code
  64520. */
  64521. handleVertexSide(state: NodeMaterialBuildState): string;
  64522. /**
  64523. * Gets the main code of the block (fragment side)
  64524. * @param state current state of the node material building
  64525. * @param normalVarName name of the existing variable corresponding to the normal
  64526. * @returns the shader code
  64527. */
  64528. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  64529. protected _buildBlock(state: NodeMaterialBuildState): this;
  64530. protected _dumpPropertiesCode(): string;
  64531. serialize(): any;
  64532. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64533. }
  64534. }
  64535. declare module BABYLON {
  64536. /**
  64537. * Block used to implement the sheen module of the PBR material
  64538. */
  64539. export class SheenBlock extends NodeMaterialBlock {
  64540. /**
  64541. * Create a new SheenBlock
  64542. * @param name defines the block name
  64543. */
  64544. constructor(name: string);
  64545. /**
  64546. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  64547. * It allows the strength of the sheen effect to not depend on the base color of the material,
  64548. * making it easier to setup and tweak the effect
  64549. */
  64550. albedoScaling: boolean;
  64551. /**
  64552. * Defines if the sheen is linked to the sheen color.
  64553. */
  64554. linkSheenWithAlbedo: boolean;
  64555. /**
  64556. * Initialize the block and prepare the context for build
  64557. * @param state defines the state that will be used for the build
  64558. */
  64559. initialize(state: NodeMaterialBuildState): void;
  64560. /**
  64561. * Gets the current class name
  64562. * @returns the class name
  64563. */
  64564. getClassName(): string;
  64565. /**
  64566. * Gets the intensity input component
  64567. */
  64568. get intensity(): NodeMaterialConnectionPoint;
  64569. /**
  64570. * Gets the color input component
  64571. */
  64572. get color(): NodeMaterialConnectionPoint;
  64573. /**
  64574. * Gets the roughness input component
  64575. */
  64576. get roughness(): NodeMaterialConnectionPoint;
  64577. /**
  64578. * Gets the sheen object output component
  64579. */
  64580. get sheen(): NodeMaterialConnectionPoint;
  64581. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64582. /**
  64583. * Gets the main code of the block (fragment side)
  64584. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64585. * @returns the shader code
  64586. */
  64587. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  64588. protected _buildBlock(state: NodeMaterialBuildState): this;
  64589. protected _dumpPropertiesCode(): string;
  64590. serialize(): any;
  64591. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64592. }
  64593. }
  64594. declare module BABYLON {
  64595. /**
  64596. * Block used to implement the reflectivity module of the PBR material
  64597. */
  64598. export class ReflectivityBlock extends NodeMaterialBlock {
  64599. private _metallicReflectanceColor;
  64600. private _metallicF0Factor;
  64601. /** @hidden */
  64602. _vMetallicReflectanceFactorsName: string;
  64603. /**
  64604. * The property below is set by the main PBR block prior to calling methods of this class.
  64605. */
  64606. /** @hidden */
  64607. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  64608. /**
  64609. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  64610. */
  64611. useAmbientOcclusionFromMetallicTextureRed: boolean;
  64612. /**
  64613. * Specifies if the metallic texture contains the metallness information in its blue channel.
  64614. */
  64615. useMetallnessFromMetallicTextureBlue: boolean;
  64616. /**
  64617. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  64618. */
  64619. useRoughnessFromMetallicTextureAlpha: boolean;
  64620. /**
  64621. * Specifies if the metallic texture contains the roughness information in its green channel.
  64622. */
  64623. useRoughnessFromMetallicTextureGreen: boolean;
  64624. /**
  64625. * Create a new ReflectivityBlock
  64626. * @param name defines the block name
  64627. */
  64628. constructor(name: string);
  64629. /**
  64630. * Initialize the block and prepare the context for build
  64631. * @param state defines the state that will be used for the build
  64632. */
  64633. initialize(state: NodeMaterialBuildState): void;
  64634. /**
  64635. * Gets the current class name
  64636. * @returns the class name
  64637. */
  64638. getClassName(): string;
  64639. /**
  64640. * Gets the metallic input component
  64641. */
  64642. get metallic(): NodeMaterialConnectionPoint;
  64643. /**
  64644. * Gets the roughness input component
  64645. */
  64646. get roughness(): NodeMaterialConnectionPoint;
  64647. /**
  64648. * Gets the texture input component
  64649. */
  64650. get texture(): NodeMaterialConnectionPoint;
  64651. /**
  64652. * Gets the reflectivity object output component
  64653. */
  64654. get reflectivity(): NodeMaterialConnectionPoint;
  64655. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64656. /**
  64657. * Gets the main code of the block (fragment side)
  64658. * @param state current state of the node material building
  64659. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  64660. * @returns the shader code
  64661. */
  64662. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  64663. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64664. protected _buildBlock(state: NodeMaterialBuildState): this;
  64665. protected _dumpPropertiesCode(): string;
  64666. serialize(): any;
  64667. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64668. }
  64669. }
  64670. declare module BABYLON {
  64671. /**
  64672. * Block used to implement the anisotropy module of the PBR material
  64673. */
  64674. export class AnisotropyBlock extends NodeMaterialBlock {
  64675. /**
  64676. * The two properties below are set by the main PBR block prior to calling methods of this class.
  64677. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64678. * It's less burden on the user side in the editor part.
  64679. */
  64680. /** @hidden */
  64681. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64682. /** @hidden */
  64683. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64684. /**
  64685. * Create a new AnisotropyBlock
  64686. * @param name defines the block name
  64687. */
  64688. constructor(name: string);
  64689. /**
  64690. * Initialize the block and prepare the context for build
  64691. * @param state defines the state that will be used for the build
  64692. */
  64693. initialize(state: NodeMaterialBuildState): void;
  64694. /**
  64695. * Gets the current class name
  64696. * @returns the class name
  64697. */
  64698. getClassName(): string;
  64699. /**
  64700. * Gets the intensity input component
  64701. */
  64702. get intensity(): NodeMaterialConnectionPoint;
  64703. /**
  64704. * Gets the direction input component
  64705. */
  64706. get direction(): NodeMaterialConnectionPoint;
  64707. /**
  64708. * Gets the texture input component
  64709. */
  64710. get texture(): NodeMaterialConnectionPoint;
  64711. /**
  64712. * Gets the uv input component
  64713. */
  64714. get uv(): NodeMaterialConnectionPoint;
  64715. /**
  64716. * Gets the worldTangent input component
  64717. */
  64718. get worldTangent(): NodeMaterialConnectionPoint;
  64719. /**
  64720. * Gets the anisotropy object output component
  64721. */
  64722. get anisotropy(): NodeMaterialConnectionPoint;
  64723. private _generateTBNSpace;
  64724. /**
  64725. * Gets the main code of the block (fragment side)
  64726. * @param state current state of the node material building
  64727. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64728. * @returns the shader code
  64729. */
  64730. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  64731. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64732. protected _buildBlock(state: NodeMaterialBuildState): this;
  64733. }
  64734. }
  64735. declare module BABYLON {
  64736. /**
  64737. * Block used to implement the clear coat module of the PBR material
  64738. */
  64739. export class ClearCoatBlock extends NodeMaterialBlock {
  64740. private _scene;
  64741. /**
  64742. * Create a new ClearCoatBlock
  64743. * @param name defines the block name
  64744. */
  64745. constructor(name: string);
  64746. /**
  64747. * Initialize the block and prepare the context for build
  64748. * @param state defines the state that will be used for the build
  64749. */
  64750. initialize(state: NodeMaterialBuildState): void;
  64751. /**
  64752. * Gets the current class name
  64753. * @returns the class name
  64754. */
  64755. getClassName(): string;
  64756. /**
  64757. * Gets the intensity input component
  64758. */
  64759. get intensity(): NodeMaterialConnectionPoint;
  64760. /**
  64761. * Gets the roughness input component
  64762. */
  64763. get roughness(): NodeMaterialConnectionPoint;
  64764. /**
  64765. * Gets the ior input component
  64766. */
  64767. get ior(): NodeMaterialConnectionPoint;
  64768. /**
  64769. * Gets the texture input component
  64770. */
  64771. get texture(): NodeMaterialConnectionPoint;
  64772. /**
  64773. * Gets the bump texture input component
  64774. */
  64775. get bumpTexture(): NodeMaterialConnectionPoint;
  64776. /**
  64777. * Gets the uv input component
  64778. */
  64779. get uv(): NodeMaterialConnectionPoint;
  64780. /**
  64781. * Gets the tint color input component
  64782. */
  64783. get tintColor(): NodeMaterialConnectionPoint;
  64784. /**
  64785. * Gets the tint "at distance" input component
  64786. */
  64787. get tintAtDistance(): NodeMaterialConnectionPoint;
  64788. /**
  64789. * Gets the tint thickness input component
  64790. */
  64791. get tintThickness(): NodeMaterialConnectionPoint;
  64792. /**
  64793. * Gets the world tangent input component
  64794. */
  64795. get worldTangent(): NodeMaterialConnectionPoint;
  64796. /**
  64797. * Gets the clear coat object output component
  64798. */
  64799. get clearcoat(): NodeMaterialConnectionPoint;
  64800. autoConfigure(material: NodeMaterial): void;
  64801. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64802. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64803. private _generateTBNSpace;
  64804. /**
  64805. * Gets the main code of the block (fragment side)
  64806. * @param state current state of the node material building
  64807. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  64808. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64809. * @param worldPosVarName name of the variable holding the world position
  64810. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64811. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  64812. * @param worldNormalVarName name of the variable holding the world normal
  64813. * @returns the shader code
  64814. */
  64815. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  64816. protected _buildBlock(state: NodeMaterialBuildState): this;
  64817. }
  64818. }
  64819. declare module BABYLON {
  64820. /**
  64821. * Block used to implement the sub surface module of the PBR material
  64822. */
  64823. export class SubSurfaceBlock extends NodeMaterialBlock {
  64824. /**
  64825. * Create a new SubSurfaceBlock
  64826. * @param name defines the block name
  64827. */
  64828. constructor(name: string);
  64829. /**
  64830. * Stores the intensity of the different subsurface effects in the thickness texture.
  64831. * * the green channel is the translucency intensity.
  64832. * * the blue channel is the scattering intensity.
  64833. * * the alpha channel is the refraction intensity.
  64834. */
  64835. useMaskFromThicknessTexture: boolean;
  64836. /**
  64837. * Initialize the block and prepare the context for build
  64838. * @param state defines the state that will be used for the build
  64839. */
  64840. initialize(state: NodeMaterialBuildState): void;
  64841. /**
  64842. * Gets the current class name
  64843. * @returns the class name
  64844. */
  64845. getClassName(): string;
  64846. /**
  64847. * Gets the min thickness input component
  64848. */
  64849. get minThickness(): NodeMaterialConnectionPoint;
  64850. /**
  64851. * Gets the max thickness input component
  64852. */
  64853. get maxThickness(): NodeMaterialConnectionPoint;
  64854. /**
  64855. * Gets the thickness texture component
  64856. */
  64857. get thicknessTexture(): NodeMaterialConnectionPoint;
  64858. /**
  64859. * Gets the tint color input component
  64860. */
  64861. get tintColor(): NodeMaterialConnectionPoint;
  64862. /**
  64863. * Gets the translucency intensity input component
  64864. */
  64865. get translucencyIntensity(): NodeMaterialConnectionPoint;
  64866. /**
  64867. * Gets the translucency diffusion distance input component
  64868. */
  64869. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  64870. /**
  64871. * Gets the refraction object parameters
  64872. */
  64873. get refraction(): NodeMaterialConnectionPoint;
  64874. /**
  64875. * Gets the sub surface object output component
  64876. */
  64877. get subsurface(): NodeMaterialConnectionPoint;
  64878. autoConfigure(material: NodeMaterial): void;
  64879. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64880. /**
  64881. * Gets the main code of the block (fragment side)
  64882. * @param state current state of the node material building
  64883. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  64884. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64885. * @param worldPosVarName name of the variable holding the world position
  64886. * @returns the shader code
  64887. */
  64888. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  64889. protected _buildBlock(state: NodeMaterialBuildState): this;
  64890. }
  64891. }
  64892. declare module BABYLON {
  64893. /**
  64894. * Block used to implement the PBR metallic/roughness model
  64895. */
  64896. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  64897. /**
  64898. * Gets or sets the light associated with this block
  64899. */
  64900. light: Nullable<Light>;
  64901. private _lightId;
  64902. private _scene;
  64903. private _environmentBRDFTexture;
  64904. private _environmentBrdfSamplerName;
  64905. private _vNormalWName;
  64906. private _invertNormalName;
  64907. /**
  64908. * Create a new ReflectionBlock
  64909. * @param name defines the block name
  64910. */
  64911. constructor(name: string);
  64912. /**
  64913. * Intensity of the direct lights e.g. the four lights available in your scene.
  64914. * This impacts both the direct diffuse and specular highlights.
  64915. */
  64916. directIntensity: number;
  64917. /**
  64918. * Intensity of the environment e.g. how much the environment will light the object
  64919. * either through harmonics for rough material or through the refelction for shiny ones.
  64920. */
  64921. environmentIntensity: number;
  64922. /**
  64923. * This is a special control allowing the reduction of the specular highlights coming from the
  64924. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  64925. */
  64926. specularIntensity: number;
  64927. /**
  64928. * Defines the falloff type used in this material.
  64929. * It by default is Physical.
  64930. */
  64931. lightFalloff: number;
  64932. /**
  64933. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  64934. */
  64935. useAlphaFromAlbedoTexture: boolean;
  64936. /**
  64937. * Specifies that alpha test should be used
  64938. */
  64939. useAlphaTest: boolean;
  64940. /**
  64941. * Defines the alpha limits in alpha test mode.
  64942. */
  64943. alphaTestCutoff: number;
  64944. /**
  64945. * Specifies that alpha blending should be used
  64946. */
  64947. useAlphaBlending: boolean;
  64948. /**
  64949. * Defines if the alpha value should be determined via the rgb values.
  64950. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  64951. */
  64952. opacityRGB: boolean;
  64953. /**
  64954. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  64955. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  64956. */
  64957. useRadianceOverAlpha: boolean;
  64958. /**
  64959. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  64960. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  64961. */
  64962. useSpecularOverAlpha: boolean;
  64963. /**
  64964. * Enables specular anti aliasing in the PBR shader.
  64965. * It will both interacts on the Geometry for analytical and IBL lighting.
  64966. * It also prefilter the roughness map based on the bump values.
  64967. */
  64968. enableSpecularAntiAliasing: boolean;
  64969. /**
  64970. * Enables realtime filtering on the texture.
  64971. */
  64972. realTimeFiltering: boolean;
  64973. /**
  64974. * Quality switch for realtime filtering
  64975. */
  64976. realTimeFilteringQuality: number;
  64977. /**
  64978. * Defines if the material uses energy conservation.
  64979. */
  64980. useEnergyConservation: boolean;
  64981. /**
  64982. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  64983. * too much the area relying on ambient texture to define their ambient occlusion.
  64984. */
  64985. useRadianceOcclusion: boolean;
  64986. /**
  64987. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  64988. * makes the reflect vector face the model (under horizon).
  64989. */
  64990. useHorizonOcclusion: boolean;
  64991. /**
  64992. * If set to true, no lighting calculations will be applied.
  64993. */
  64994. unlit: boolean;
  64995. /**
  64996. * Force normal to face away from face.
  64997. */
  64998. forceNormalForward: boolean;
  64999. /**
  65000. * Defines the material debug mode.
  65001. * It helps seeing only some components of the material while troubleshooting.
  65002. */
  65003. debugMode: number;
  65004. /**
  65005. * Specify from where on screen the debug mode should start.
  65006. * The value goes from -1 (full screen) to 1 (not visible)
  65007. * It helps with side by side comparison against the final render
  65008. * This defaults to 0
  65009. */
  65010. debugLimit: number;
  65011. /**
  65012. * As the default viewing range might not be enough (if the ambient is really small for instance)
  65013. * You can use the factor to better multiply the final value.
  65014. */
  65015. debugFactor: number;
  65016. /**
  65017. * Initialize the block and prepare the context for build
  65018. * @param state defines the state that will be used for the build
  65019. */
  65020. initialize(state: NodeMaterialBuildState): void;
  65021. /**
  65022. * Gets the current class name
  65023. * @returns the class name
  65024. */
  65025. getClassName(): string;
  65026. /**
  65027. * Gets the world position input component
  65028. */
  65029. get worldPosition(): NodeMaterialConnectionPoint;
  65030. /**
  65031. * Gets the world normal input component
  65032. */
  65033. get worldNormal(): NodeMaterialConnectionPoint;
  65034. /**
  65035. * Gets the perturbed normal input component
  65036. */
  65037. get perturbedNormal(): NodeMaterialConnectionPoint;
  65038. /**
  65039. * Gets the camera position input component
  65040. */
  65041. get cameraPosition(): NodeMaterialConnectionPoint;
  65042. /**
  65043. * Gets the base color input component
  65044. */
  65045. get baseColor(): NodeMaterialConnectionPoint;
  65046. /**
  65047. * Gets the opacity texture input component
  65048. */
  65049. get opacityTexture(): NodeMaterialConnectionPoint;
  65050. /**
  65051. * Gets the ambient color input component
  65052. */
  65053. get ambientColor(): NodeMaterialConnectionPoint;
  65054. /**
  65055. * Gets the reflectivity object parameters
  65056. */
  65057. get reflectivity(): NodeMaterialConnectionPoint;
  65058. /**
  65059. * Gets the ambient occlusion object parameters
  65060. */
  65061. get ambientOcclusion(): NodeMaterialConnectionPoint;
  65062. /**
  65063. * Gets the reflection object parameters
  65064. */
  65065. get reflection(): NodeMaterialConnectionPoint;
  65066. /**
  65067. * Gets the sheen object parameters
  65068. */
  65069. get sheen(): NodeMaterialConnectionPoint;
  65070. /**
  65071. * Gets the clear coat object parameters
  65072. */
  65073. get clearcoat(): NodeMaterialConnectionPoint;
  65074. /**
  65075. * Gets the sub surface object parameters
  65076. */
  65077. get subsurface(): NodeMaterialConnectionPoint;
  65078. /**
  65079. * Gets the anisotropy object parameters
  65080. */
  65081. get anisotropy(): NodeMaterialConnectionPoint;
  65082. /**
  65083. * Gets the ambient output component
  65084. */
  65085. get ambient(): NodeMaterialConnectionPoint;
  65086. /**
  65087. * Gets the diffuse output component
  65088. */
  65089. get diffuse(): NodeMaterialConnectionPoint;
  65090. /**
  65091. * Gets the specular output component
  65092. */
  65093. get specular(): NodeMaterialConnectionPoint;
  65094. /**
  65095. * Gets the sheen output component
  65096. */
  65097. get sheenDir(): NodeMaterialConnectionPoint;
  65098. /**
  65099. * Gets the clear coat output component
  65100. */
  65101. get clearcoatDir(): NodeMaterialConnectionPoint;
  65102. /**
  65103. * Gets the indirect diffuse output component
  65104. */
  65105. get diffuseIndirect(): NodeMaterialConnectionPoint;
  65106. /**
  65107. * Gets the indirect specular output component
  65108. */
  65109. get specularIndirect(): NodeMaterialConnectionPoint;
  65110. /**
  65111. * Gets the indirect sheen output component
  65112. */
  65113. get sheenIndirect(): NodeMaterialConnectionPoint;
  65114. /**
  65115. * Gets the indirect clear coat output component
  65116. */
  65117. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  65118. /**
  65119. * Gets the refraction output component
  65120. */
  65121. get refraction(): NodeMaterialConnectionPoint;
  65122. /**
  65123. * Gets the global lighting output component
  65124. */
  65125. get lighting(): NodeMaterialConnectionPoint;
  65126. /**
  65127. * Gets the shadow output component
  65128. */
  65129. get shadow(): NodeMaterialConnectionPoint;
  65130. /**
  65131. * Gets the alpha output component
  65132. */
  65133. get alpha(): NodeMaterialConnectionPoint;
  65134. autoConfigure(material: NodeMaterial): void;
  65135. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65136. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  65137. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65138. private _injectVertexCode;
  65139. /**
  65140. * Gets the code corresponding to the albedo/opacity module
  65141. * @returns the shader code
  65142. */
  65143. getAlbedoOpacityCode(): string;
  65144. protected _buildBlock(state: NodeMaterialBuildState): this;
  65145. protected _dumpPropertiesCode(): string;
  65146. serialize(): any;
  65147. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65148. }
  65149. }
  65150. declare module BABYLON {
  65151. /**
  65152. * Block used to compute value of one parameter modulo another
  65153. */
  65154. export class ModBlock extends NodeMaterialBlock {
  65155. /**
  65156. * Creates a new ModBlock
  65157. * @param name defines the block name
  65158. */
  65159. constructor(name: string);
  65160. /**
  65161. * Gets the current class name
  65162. * @returns the class name
  65163. */
  65164. getClassName(): string;
  65165. /**
  65166. * Gets the left operand input component
  65167. */
  65168. get left(): NodeMaterialConnectionPoint;
  65169. /**
  65170. * Gets the right operand input component
  65171. */
  65172. get right(): NodeMaterialConnectionPoint;
  65173. /**
  65174. * Gets the output component
  65175. */
  65176. get output(): NodeMaterialConnectionPoint;
  65177. protected _buildBlock(state: NodeMaterialBuildState): this;
  65178. }
  65179. }
  65180. declare module BABYLON {
  65181. /**
  65182. * Configuration for Draco compression
  65183. */
  65184. export interface IDracoCompressionConfiguration {
  65185. /**
  65186. * Configuration for the decoder.
  65187. */
  65188. decoder: {
  65189. /**
  65190. * The url to the WebAssembly module.
  65191. */
  65192. wasmUrl?: string;
  65193. /**
  65194. * The url to the WebAssembly binary.
  65195. */
  65196. wasmBinaryUrl?: string;
  65197. /**
  65198. * The url to the fallback JavaScript module.
  65199. */
  65200. fallbackUrl?: string;
  65201. };
  65202. }
  65203. /**
  65204. * Draco compression (https://google.github.io/draco/)
  65205. *
  65206. * This class wraps the Draco module.
  65207. *
  65208. * **Encoder**
  65209. *
  65210. * The encoder is not currently implemented.
  65211. *
  65212. * **Decoder**
  65213. *
  65214. * 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.
  65215. *
  65216. * To update the configuration, use the following code:
  65217. * ```javascript
  65218. * DracoCompression.Configuration = {
  65219. * decoder: {
  65220. * wasmUrl: "<url to the WebAssembly library>",
  65221. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  65222. * fallbackUrl: "<url to the fallback JavaScript library>",
  65223. * }
  65224. * };
  65225. * ```
  65226. *
  65227. * 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.
  65228. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  65229. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  65230. *
  65231. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  65232. * ```javascript
  65233. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  65234. * ```
  65235. *
  65236. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  65237. */
  65238. export class DracoCompression implements IDisposable {
  65239. private _workerPoolPromise?;
  65240. private _decoderModulePromise?;
  65241. /**
  65242. * The configuration. Defaults to the following urls:
  65243. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  65244. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  65245. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  65246. */
  65247. static Configuration: IDracoCompressionConfiguration;
  65248. /**
  65249. * Returns true if the decoder configuration is available.
  65250. */
  65251. static get DecoderAvailable(): boolean;
  65252. /**
  65253. * Default number of workers to create when creating the draco compression object.
  65254. */
  65255. static DefaultNumWorkers: number;
  65256. private static GetDefaultNumWorkers;
  65257. private static _Default;
  65258. /**
  65259. * Default instance for the draco compression object.
  65260. */
  65261. static get Default(): DracoCompression;
  65262. /**
  65263. * Constructor
  65264. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  65265. */
  65266. constructor(numWorkers?: number);
  65267. /**
  65268. * Stop all async operations and release resources.
  65269. */
  65270. dispose(): void;
  65271. /**
  65272. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  65273. * @returns a promise that resolves when ready
  65274. */
  65275. whenReadyAsync(): Promise<void>;
  65276. /**
  65277. * Decode Draco compressed mesh data to vertex data.
  65278. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  65279. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  65280. * @returns A promise that resolves with the decoded vertex data
  65281. */
  65282. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  65283. [kind: string]: number;
  65284. }): Promise<VertexData>;
  65285. }
  65286. }
  65287. declare module BABYLON {
  65288. /**
  65289. * Class for building Constructive Solid Geometry
  65290. */
  65291. export class CSG {
  65292. private polygons;
  65293. /**
  65294. * The world matrix
  65295. */
  65296. matrix: Matrix;
  65297. /**
  65298. * Stores the position
  65299. */
  65300. position: Vector3;
  65301. /**
  65302. * Stores the rotation
  65303. */
  65304. rotation: Vector3;
  65305. /**
  65306. * Stores the rotation quaternion
  65307. */
  65308. rotationQuaternion: Nullable<Quaternion>;
  65309. /**
  65310. * Stores the scaling vector
  65311. */
  65312. scaling: Vector3;
  65313. /**
  65314. * Convert the Mesh to CSG
  65315. * @param mesh The Mesh to convert to CSG
  65316. * @returns A new CSG from the Mesh
  65317. */
  65318. static FromMesh(mesh: Mesh): CSG;
  65319. /**
  65320. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  65321. * @param polygons Polygons used to construct a CSG solid
  65322. */
  65323. private static FromPolygons;
  65324. /**
  65325. * Clones, or makes a deep copy, of the CSG
  65326. * @returns A new CSG
  65327. */
  65328. clone(): CSG;
  65329. /**
  65330. * Unions this CSG with another CSG
  65331. * @param csg The CSG to union against this CSG
  65332. * @returns The unioned CSG
  65333. */
  65334. union(csg: CSG): CSG;
  65335. /**
  65336. * Unions this CSG with another CSG in place
  65337. * @param csg The CSG to union against this CSG
  65338. */
  65339. unionInPlace(csg: CSG): void;
  65340. /**
  65341. * Subtracts this CSG with another CSG
  65342. * @param csg The CSG to subtract against this CSG
  65343. * @returns A new CSG
  65344. */
  65345. subtract(csg: CSG): CSG;
  65346. /**
  65347. * Subtracts this CSG with another CSG in place
  65348. * @param csg The CSG to subtact against this CSG
  65349. */
  65350. subtractInPlace(csg: CSG): void;
  65351. /**
  65352. * Intersect this CSG with another CSG
  65353. * @param csg The CSG to intersect against this CSG
  65354. * @returns A new CSG
  65355. */
  65356. intersect(csg: CSG): CSG;
  65357. /**
  65358. * Intersects this CSG with another CSG in place
  65359. * @param csg The CSG to intersect against this CSG
  65360. */
  65361. intersectInPlace(csg: CSG): void;
  65362. /**
  65363. * Return a new CSG solid with solid and empty space switched. This solid is
  65364. * not modified.
  65365. * @returns A new CSG solid with solid and empty space switched
  65366. */
  65367. inverse(): CSG;
  65368. /**
  65369. * Inverses the CSG in place
  65370. */
  65371. inverseInPlace(): void;
  65372. /**
  65373. * This is used to keep meshes transformations so they can be restored
  65374. * when we build back a Babylon Mesh
  65375. * NB : All CSG operations are performed in world coordinates
  65376. * @param csg The CSG to copy the transform attributes from
  65377. * @returns This CSG
  65378. */
  65379. copyTransformAttributes(csg: CSG): CSG;
  65380. /**
  65381. * Build Raw mesh from CSG
  65382. * Coordinates here are in world space
  65383. * @param name The name of the mesh geometry
  65384. * @param scene The Scene
  65385. * @param keepSubMeshes Specifies if the submeshes should be kept
  65386. * @returns A new Mesh
  65387. */
  65388. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65389. /**
  65390. * Build Mesh from CSG taking material and transforms into account
  65391. * @param name The name of the Mesh
  65392. * @param material The material of the Mesh
  65393. * @param scene The Scene
  65394. * @param keepSubMeshes Specifies if submeshes should be kept
  65395. * @returns The new Mesh
  65396. */
  65397. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65398. }
  65399. }
  65400. declare module BABYLON {
  65401. /**
  65402. * Class used to create a trail following a mesh
  65403. */
  65404. export class TrailMesh extends Mesh {
  65405. private _generator;
  65406. private _autoStart;
  65407. private _running;
  65408. private _diameter;
  65409. private _length;
  65410. private _sectionPolygonPointsCount;
  65411. private _sectionVectors;
  65412. private _sectionNormalVectors;
  65413. private _beforeRenderObserver;
  65414. /**
  65415. * @constructor
  65416. * @param name The value used by scene.getMeshByName() to do a lookup.
  65417. * @param generator The mesh or transform node to generate a trail.
  65418. * @param scene The scene to add this mesh to.
  65419. * @param diameter Diameter of trailing mesh. Default is 1.
  65420. * @param length Length of trailing mesh. Default is 60.
  65421. * @param autoStart Automatically start trailing mesh. Default true.
  65422. */
  65423. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  65424. /**
  65425. * "TrailMesh"
  65426. * @returns "TrailMesh"
  65427. */
  65428. getClassName(): string;
  65429. private _createMesh;
  65430. /**
  65431. * Start trailing mesh.
  65432. */
  65433. start(): void;
  65434. /**
  65435. * Stop trailing mesh.
  65436. */
  65437. stop(): void;
  65438. /**
  65439. * Update trailing mesh geometry.
  65440. */
  65441. update(): void;
  65442. /**
  65443. * Returns a new TrailMesh object.
  65444. * @param name is a string, the name given to the new mesh
  65445. * @param newGenerator use new generator object for cloned trail mesh
  65446. * @returns a new mesh
  65447. */
  65448. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  65449. /**
  65450. * Serializes this trail mesh
  65451. * @param serializationObject object to write serialization to
  65452. */
  65453. serialize(serializationObject: any): void;
  65454. /**
  65455. * Parses a serialized trail mesh
  65456. * @param parsedMesh the serialized mesh
  65457. * @param scene the scene to create the trail mesh in
  65458. * @returns the created trail mesh
  65459. */
  65460. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  65461. }
  65462. }
  65463. declare module BABYLON {
  65464. /**
  65465. * Class containing static functions to help procedurally build meshes
  65466. */
  65467. export class TiledBoxBuilder {
  65468. /**
  65469. * Creates a box mesh
  65470. * 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)
  65471. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65472. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65473. * * 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
  65474. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65475. * @param name defines the name of the mesh
  65476. * @param options defines the options used to create the mesh
  65477. * @param scene defines the hosting scene
  65478. * @returns the box mesh
  65479. */
  65480. static CreateTiledBox(name: string, options: {
  65481. pattern?: number;
  65482. width?: number;
  65483. height?: number;
  65484. depth?: number;
  65485. tileSize?: number;
  65486. tileWidth?: number;
  65487. tileHeight?: number;
  65488. alignHorizontal?: number;
  65489. alignVertical?: number;
  65490. faceUV?: Vector4[];
  65491. faceColors?: Color4[];
  65492. sideOrientation?: number;
  65493. updatable?: boolean;
  65494. }, scene?: Nullable<Scene>): Mesh;
  65495. }
  65496. }
  65497. declare module BABYLON {
  65498. /**
  65499. * Class containing static functions to help procedurally build meshes
  65500. */
  65501. export class TorusKnotBuilder {
  65502. /**
  65503. * Creates a torus knot mesh
  65504. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  65505. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  65506. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  65507. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  65508. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65509. * * 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
  65510. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65511. * @param name defines the name of the mesh
  65512. * @param options defines the options used to create the mesh
  65513. * @param scene defines the hosting scene
  65514. * @returns the torus knot mesh
  65515. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  65516. */
  65517. static CreateTorusKnot(name: string, options: {
  65518. radius?: number;
  65519. tube?: number;
  65520. radialSegments?: number;
  65521. tubularSegments?: number;
  65522. p?: number;
  65523. q?: number;
  65524. updatable?: boolean;
  65525. sideOrientation?: number;
  65526. frontUVs?: Vector4;
  65527. backUVs?: Vector4;
  65528. }, scene: any): Mesh;
  65529. }
  65530. }
  65531. declare module BABYLON {
  65532. /**
  65533. * Polygon
  65534. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  65535. */
  65536. export class Polygon {
  65537. /**
  65538. * Creates a rectangle
  65539. * @param xmin bottom X coord
  65540. * @param ymin bottom Y coord
  65541. * @param xmax top X coord
  65542. * @param ymax top Y coord
  65543. * @returns points that make the resulting rectation
  65544. */
  65545. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  65546. /**
  65547. * Creates a circle
  65548. * @param radius radius of circle
  65549. * @param cx scale in x
  65550. * @param cy scale in y
  65551. * @param numberOfSides number of sides that make up the circle
  65552. * @returns points that make the resulting circle
  65553. */
  65554. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  65555. /**
  65556. * Creates a polygon from input string
  65557. * @param input Input polygon data
  65558. * @returns the parsed points
  65559. */
  65560. static Parse(input: string): Vector2[];
  65561. /**
  65562. * Starts building a polygon from x and y coordinates
  65563. * @param x x coordinate
  65564. * @param y y coordinate
  65565. * @returns the started path2
  65566. */
  65567. static StartingAt(x: number, y: number): Path2;
  65568. }
  65569. /**
  65570. * Builds a polygon
  65571. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  65572. */
  65573. export class PolygonMeshBuilder {
  65574. private _points;
  65575. private _outlinepoints;
  65576. private _holes;
  65577. private _name;
  65578. private _scene;
  65579. private _epoints;
  65580. private _eholes;
  65581. private _addToepoint;
  65582. /**
  65583. * Babylon reference to the earcut plugin.
  65584. */
  65585. bjsEarcut: any;
  65586. /**
  65587. * Creates a PolygonMeshBuilder
  65588. * @param name name of the builder
  65589. * @param contours Path of the polygon
  65590. * @param scene scene to add to when creating the mesh
  65591. * @param earcutInjection can be used to inject your own earcut reference
  65592. */
  65593. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  65594. /**
  65595. * Adds a whole within the polygon
  65596. * @param hole Array of points defining the hole
  65597. * @returns this
  65598. */
  65599. addHole(hole: Vector2[]): PolygonMeshBuilder;
  65600. /**
  65601. * Creates the polygon
  65602. * @param updatable If the mesh should be updatable
  65603. * @param depth The depth of the mesh created
  65604. * @returns the created mesh
  65605. */
  65606. build(updatable?: boolean, depth?: number): Mesh;
  65607. /**
  65608. * Creates the polygon
  65609. * @param depth The depth of the mesh created
  65610. * @returns the created VertexData
  65611. */
  65612. buildVertexData(depth?: number): VertexData;
  65613. /**
  65614. * Adds a side to the polygon
  65615. * @param positions points that make the polygon
  65616. * @param normals normals of the polygon
  65617. * @param uvs uvs of the polygon
  65618. * @param indices indices of the polygon
  65619. * @param bounds bounds of the polygon
  65620. * @param points points of the polygon
  65621. * @param depth depth of the polygon
  65622. * @param flip flip of the polygon
  65623. */
  65624. private addSide;
  65625. }
  65626. }
  65627. declare module BABYLON {
  65628. /**
  65629. * Class containing static functions to help procedurally build meshes
  65630. */
  65631. export class PolygonBuilder {
  65632. /**
  65633. * Creates a polygon mesh
  65634. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65635. * * 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
  65636. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65637. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65638. * * 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)
  65639. * * Remember you can only change the shape positions, not their number when updating a polygon
  65640. * @param name defines the name of the mesh
  65641. * @param options defines the options used to create the mesh
  65642. * @param scene defines the hosting scene
  65643. * @param earcutInjection can be used to inject your own earcut reference
  65644. * @returns the polygon mesh
  65645. */
  65646. static CreatePolygon(name: string, options: {
  65647. shape: Vector3[];
  65648. holes?: Vector3[][];
  65649. depth?: number;
  65650. faceUV?: Vector4[];
  65651. faceColors?: Color4[];
  65652. updatable?: boolean;
  65653. sideOrientation?: number;
  65654. frontUVs?: Vector4;
  65655. backUVs?: Vector4;
  65656. wrap?: boolean;
  65657. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65658. /**
  65659. * Creates an extruded polygon mesh, with depth in the Y direction.
  65660. * * 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)
  65661. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65662. * @param name defines the name of the mesh
  65663. * @param options defines the options used to create the mesh
  65664. * @param scene defines the hosting scene
  65665. * @param earcutInjection can be used to inject your own earcut reference
  65666. * @returns the polygon mesh
  65667. */
  65668. static ExtrudePolygon(name: string, options: {
  65669. shape: Vector3[];
  65670. holes?: Vector3[][];
  65671. depth?: number;
  65672. faceUV?: Vector4[];
  65673. faceColors?: Color4[];
  65674. updatable?: boolean;
  65675. sideOrientation?: number;
  65676. frontUVs?: Vector4;
  65677. backUVs?: Vector4;
  65678. wrap?: boolean;
  65679. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65680. }
  65681. }
  65682. declare module BABYLON {
  65683. /**
  65684. * Class containing static functions to help procedurally build meshes
  65685. */
  65686. export class LatheBuilder {
  65687. /**
  65688. * Creates lathe mesh.
  65689. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  65690. * * 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
  65691. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  65692. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  65693. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  65694. * * 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
  65695. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  65696. * * 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
  65697. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65698. * * 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
  65699. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65700. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65701. * @param name defines the name of the mesh
  65702. * @param options defines the options used to create the mesh
  65703. * @param scene defines the hosting scene
  65704. * @returns the lathe mesh
  65705. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  65706. */
  65707. static CreateLathe(name: string, options: {
  65708. shape: Vector3[];
  65709. radius?: number;
  65710. tessellation?: number;
  65711. clip?: number;
  65712. arc?: number;
  65713. closed?: boolean;
  65714. updatable?: boolean;
  65715. sideOrientation?: number;
  65716. frontUVs?: Vector4;
  65717. backUVs?: Vector4;
  65718. cap?: number;
  65719. invertUV?: boolean;
  65720. }, scene?: Nullable<Scene>): Mesh;
  65721. }
  65722. }
  65723. declare module BABYLON {
  65724. /**
  65725. * Class containing static functions to help procedurally build meshes
  65726. */
  65727. export class TiledPlaneBuilder {
  65728. /**
  65729. * Creates a tiled plane mesh
  65730. * * The parameter `pattern` will, depending on value, do nothing or
  65731. * * * flip (reflect about central vertical) alternate tiles across and up
  65732. * * * flip every tile on alternate rows
  65733. * * * rotate (180 degs) alternate tiles across and up
  65734. * * * rotate every tile on alternate rows
  65735. * * * flip and rotate alternate tiles across and up
  65736. * * * flip and rotate every tile on alternate rows
  65737. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  65738. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  65739. * * 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
  65740. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65741. * * 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)
  65742. * * 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)
  65743. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65744. * @param name defines the name of the mesh
  65745. * @param options defines the options used to create the mesh
  65746. * @param scene defines the hosting scene
  65747. * @returns the box mesh
  65748. */
  65749. static CreateTiledPlane(name: string, options: {
  65750. pattern?: number;
  65751. tileSize?: number;
  65752. tileWidth?: number;
  65753. tileHeight?: number;
  65754. size?: number;
  65755. width?: number;
  65756. height?: number;
  65757. alignHorizontal?: number;
  65758. alignVertical?: number;
  65759. sideOrientation?: number;
  65760. frontUVs?: Vector4;
  65761. backUVs?: Vector4;
  65762. updatable?: boolean;
  65763. }, scene?: Nullable<Scene>): Mesh;
  65764. }
  65765. }
  65766. declare module BABYLON {
  65767. /**
  65768. * Class containing static functions to help procedurally build meshes
  65769. */
  65770. export class TubeBuilder {
  65771. /**
  65772. * Creates a tube mesh.
  65773. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65774. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65775. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65776. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65777. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65778. * * 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)
  65779. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65780. * * 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
  65781. * * 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
  65782. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65783. * * 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
  65784. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65785. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65786. * @param name defines the name of the mesh
  65787. * @param options defines the options used to create the mesh
  65788. * @param scene defines the hosting scene
  65789. * @returns the tube mesh
  65790. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65791. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65792. */
  65793. static CreateTube(name: string, options: {
  65794. path: Vector3[];
  65795. radius?: number;
  65796. tessellation?: number;
  65797. radiusFunction?: {
  65798. (i: number, distance: number): number;
  65799. };
  65800. cap?: number;
  65801. arc?: number;
  65802. updatable?: boolean;
  65803. sideOrientation?: number;
  65804. frontUVs?: Vector4;
  65805. backUVs?: Vector4;
  65806. instance?: Mesh;
  65807. invertUV?: boolean;
  65808. }, scene?: Nullable<Scene>): Mesh;
  65809. }
  65810. }
  65811. declare module BABYLON {
  65812. /**
  65813. * Class containing static functions to help procedurally build meshes
  65814. */
  65815. export class IcoSphereBuilder {
  65816. /**
  65817. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65818. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65819. * * 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`)
  65820. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65821. * * 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
  65822. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65823. * * 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
  65824. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65825. * @param name defines the name of the mesh
  65826. * @param options defines the options used to create the mesh
  65827. * @param scene defines the hosting scene
  65828. * @returns the icosahedron mesh
  65829. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  65830. */
  65831. static CreateIcoSphere(name: string, options: {
  65832. radius?: number;
  65833. radiusX?: number;
  65834. radiusY?: number;
  65835. radiusZ?: number;
  65836. flat?: boolean;
  65837. subdivisions?: number;
  65838. sideOrientation?: number;
  65839. frontUVs?: Vector4;
  65840. backUVs?: Vector4;
  65841. updatable?: boolean;
  65842. }, scene?: Nullable<Scene>): Mesh;
  65843. }
  65844. }
  65845. declare module BABYLON {
  65846. /**
  65847. * Class containing static functions to help procedurally build meshes
  65848. */
  65849. export class DecalBuilder {
  65850. /**
  65851. * Creates a decal mesh.
  65852. * 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
  65853. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65854. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65855. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65856. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65857. * @param name defines the name of the mesh
  65858. * @param sourceMesh defines the mesh where the decal must be applied
  65859. * @param options defines the options used to create the mesh
  65860. * @param scene defines the hosting scene
  65861. * @returns the decal mesh
  65862. * @see https://doc.babylonjs.com/how_to/decals
  65863. */
  65864. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65865. position?: Vector3;
  65866. normal?: Vector3;
  65867. size?: Vector3;
  65868. angle?: number;
  65869. }): Mesh;
  65870. }
  65871. }
  65872. declare module BABYLON {
  65873. /**
  65874. * Class containing static functions to help procedurally build meshes
  65875. */
  65876. export class MeshBuilder {
  65877. /**
  65878. * Creates a box mesh
  65879. * * The parameter `size` sets the size (float) of each box side (default 1)
  65880. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  65881. * * 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)
  65882. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65883. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65884. * * 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
  65885. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65886. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65887. * @param name defines the name of the mesh
  65888. * @param options defines the options used to create the mesh
  65889. * @param scene defines the hosting scene
  65890. * @returns the box mesh
  65891. */
  65892. static CreateBox(name: string, options: {
  65893. size?: number;
  65894. width?: number;
  65895. height?: number;
  65896. depth?: number;
  65897. faceUV?: Vector4[];
  65898. faceColors?: Color4[];
  65899. sideOrientation?: number;
  65900. frontUVs?: Vector4;
  65901. backUVs?: Vector4;
  65902. wrap?: boolean;
  65903. topBaseAt?: number;
  65904. bottomBaseAt?: number;
  65905. updatable?: boolean;
  65906. }, scene?: Nullable<Scene>): Mesh;
  65907. /**
  65908. * Creates a tiled box mesh
  65909. * * faceTiles sets the pattern, tile size and number of tiles for a face
  65910. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65911. * @param name defines the name of the mesh
  65912. * @param options defines the options used to create the mesh
  65913. * @param scene defines the hosting scene
  65914. * @returns the tiled box mesh
  65915. */
  65916. static CreateTiledBox(name: string, options: {
  65917. pattern?: number;
  65918. size?: number;
  65919. width?: number;
  65920. height?: number;
  65921. depth: number;
  65922. tileSize?: number;
  65923. tileWidth?: number;
  65924. tileHeight?: number;
  65925. faceUV?: Vector4[];
  65926. faceColors?: Color4[];
  65927. alignHorizontal?: number;
  65928. alignVertical?: number;
  65929. sideOrientation?: number;
  65930. updatable?: boolean;
  65931. }, scene?: Nullable<Scene>): Mesh;
  65932. /**
  65933. * Creates a sphere mesh
  65934. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  65935. * * 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`)
  65936. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  65937. * * 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
  65938. * * 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)
  65939. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65940. * * 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
  65941. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65942. * @param name defines the name of the mesh
  65943. * @param options defines the options used to create the mesh
  65944. * @param scene defines the hosting scene
  65945. * @returns the sphere mesh
  65946. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  65947. */
  65948. static CreateSphere(name: string, options: {
  65949. segments?: number;
  65950. diameter?: number;
  65951. diameterX?: number;
  65952. diameterY?: number;
  65953. diameterZ?: number;
  65954. arc?: number;
  65955. slice?: number;
  65956. sideOrientation?: number;
  65957. frontUVs?: Vector4;
  65958. backUVs?: Vector4;
  65959. updatable?: boolean;
  65960. }, scene?: Nullable<Scene>): Mesh;
  65961. /**
  65962. * Creates a plane polygonal mesh. By default, this is a disc
  65963. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  65964. * * 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
  65965. * * 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
  65966. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65967. * * 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
  65968. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65969. * @param name defines the name of the mesh
  65970. * @param options defines the options used to create the mesh
  65971. * @param scene defines the hosting scene
  65972. * @returns the plane polygonal mesh
  65973. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  65974. */
  65975. static CreateDisc(name: string, options: {
  65976. radius?: number;
  65977. tessellation?: number;
  65978. arc?: number;
  65979. updatable?: boolean;
  65980. sideOrientation?: number;
  65981. frontUVs?: Vector4;
  65982. backUVs?: Vector4;
  65983. }, scene?: Nullable<Scene>): Mesh;
  65984. /**
  65985. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65986. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65987. * * 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`)
  65988. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65989. * * 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
  65990. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65991. * * 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
  65992. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65993. * @param name defines the name of the mesh
  65994. * @param options defines the options used to create the mesh
  65995. * @param scene defines the hosting scene
  65996. * @returns the icosahedron mesh
  65997. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  65998. */
  65999. static CreateIcoSphere(name: string, options: {
  66000. radius?: number;
  66001. radiusX?: number;
  66002. radiusY?: number;
  66003. radiusZ?: number;
  66004. flat?: boolean;
  66005. subdivisions?: number;
  66006. sideOrientation?: number;
  66007. frontUVs?: Vector4;
  66008. backUVs?: Vector4;
  66009. updatable?: boolean;
  66010. }, scene?: Nullable<Scene>): Mesh;
  66011. /**
  66012. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66013. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  66014. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  66015. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  66016. * * 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
  66017. * * 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
  66018. * * 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
  66019. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66020. * * 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
  66021. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66022. * * 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
  66023. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  66024. * * 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
  66025. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  66026. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66027. * @param name defines the name of the mesh
  66028. * @param options defines the options used to create the mesh
  66029. * @param scene defines the hosting scene
  66030. * @returns the ribbon mesh
  66031. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  66032. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66033. */
  66034. static CreateRibbon(name: string, options: {
  66035. pathArray: Vector3[][];
  66036. closeArray?: boolean;
  66037. closePath?: boolean;
  66038. offset?: number;
  66039. updatable?: boolean;
  66040. sideOrientation?: number;
  66041. frontUVs?: Vector4;
  66042. backUVs?: Vector4;
  66043. instance?: Mesh;
  66044. invertUV?: boolean;
  66045. uvs?: Vector2[];
  66046. colors?: Color4[];
  66047. }, scene?: Nullable<Scene>): Mesh;
  66048. /**
  66049. * Creates a cylinder or a cone mesh
  66050. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  66051. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  66052. * * 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.
  66053. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  66054. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  66055. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  66056. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  66057. * * 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).
  66058. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  66059. * * 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).
  66060. * * 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
  66061. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  66062. * * 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
  66063. * * 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.
  66064. * * If `enclose` is false, a ring surface is one element.
  66065. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  66066. * * 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
  66067. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66068. * * 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
  66069. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66070. * @param name defines the name of the mesh
  66071. * @param options defines the options used to create the mesh
  66072. * @param scene defines the hosting scene
  66073. * @returns the cylinder mesh
  66074. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  66075. */
  66076. static CreateCylinder(name: string, options: {
  66077. height?: number;
  66078. diameterTop?: number;
  66079. diameterBottom?: number;
  66080. diameter?: number;
  66081. tessellation?: number;
  66082. subdivisions?: number;
  66083. arc?: number;
  66084. faceColors?: Color4[];
  66085. faceUV?: Vector4[];
  66086. updatable?: boolean;
  66087. hasRings?: boolean;
  66088. enclose?: boolean;
  66089. cap?: number;
  66090. sideOrientation?: number;
  66091. frontUVs?: Vector4;
  66092. backUVs?: Vector4;
  66093. }, scene?: Nullable<Scene>): Mesh;
  66094. /**
  66095. * Creates a torus mesh
  66096. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  66097. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  66098. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  66099. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66100. * * 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
  66101. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66102. * @param name defines the name of the mesh
  66103. * @param options defines the options used to create the mesh
  66104. * @param scene defines the hosting scene
  66105. * @returns the torus mesh
  66106. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  66107. */
  66108. static CreateTorus(name: string, options: {
  66109. diameter?: number;
  66110. thickness?: number;
  66111. tessellation?: number;
  66112. updatable?: boolean;
  66113. sideOrientation?: number;
  66114. frontUVs?: Vector4;
  66115. backUVs?: Vector4;
  66116. }, scene?: Nullable<Scene>): Mesh;
  66117. /**
  66118. * Creates a torus knot mesh
  66119. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66120. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66121. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66122. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66123. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66124. * * 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
  66125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66126. * @param name defines the name of the mesh
  66127. * @param options defines the options used to create the mesh
  66128. * @param scene defines the hosting scene
  66129. * @returns the torus knot mesh
  66130. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66131. */
  66132. static CreateTorusKnot(name: string, options: {
  66133. radius?: number;
  66134. tube?: number;
  66135. radialSegments?: number;
  66136. tubularSegments?: number;
  66137. p?: number;
  66138. q?: number;
  66139. updatable?: boolean;
  66140. sideOrientation?: number;
  66141. frontUVs?: Vector4;
  66142. backUVs?: Vector4;
  66143. }, scene?: Nullable<Scene>): Mesh;
  66144. /**
  66145. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  66146. * * 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
  66147. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  66148. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  66149. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  66150. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  66151. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  66152. * * 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
  66153. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  66154. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66155. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  66156. * @param name defines the name of the new line system
  66157. * @param options defines the options used to create the line system
  66158. * @param scene defines the hosting scene
  66159. * @returns a new line system mesh
  66160. */
  66161. static CreateLineSystem(name: string, options: {
  66162. lines: Vector3[][];
  66163. updatable?: boolean;
  66164. instance?: Nullable<LinesMesh>;
  66165. colors?: Nullable<Color4[][]>;
  66166. useVertexAlpha?: boolean;
  66167. }, scene: Nullable<Scene>): LinesMesh;
  66168. /**
  66169. * Creates a line mesh
  66170. * 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
  66171. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66172. * * The parameter `points` is an array successive Vector3
  66173. * * 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
  66174. * * The optional parameter `colors` is an array of successive Color4, one per line point
  66175. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  66176. * * When updating an instance, remember that only point positions can change, not the number of points
  66177. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66178. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  66179. * @param name defines the name of the new line system
  66180. * @param options defines the options used to create the line system
  66181. * @param scene defines the hosting scene
  66182. * @returns a new line mesh
  66183. */
  66184. static CreateLines(name: string, options: {
  66185. points: Vector3[];
  66186. updatable?: boolean;
  66187. instance?: Nullable<LinesMesh>;
  66188. colors?: Color4[];
  66189. useVertexAlpha?: boolean;
  66190. }, scene?: Nullable<Scene>): LinesMesh;
  66191. /**
  66192. * Creates a dashed line mesh
  66193. * * 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
  66194. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66195. * * The parameter `points` is an array successive Vector3
  66196. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  66197. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  66198. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  66199. * * 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
  66200. * * When updating an instance, remember that only point positions can change, not the number of points
  66201. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66202. * @param name defines the name of the mesh
  66203. * @param options defines the options used to create the mesh
  66204. * @param scene defines the hosting scene
  66205. * @returns the dashed line mesh
  66206. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  66207. */
  66208. static CreateDashedLines(name: string, options: {
  66209. points: Vector3[];
  66210. dashSize?: number;
  66211. gapSize?: number;
  66212. dashNb?: number;
  66213. updatable?: boolean;
  66214. instance?: LinesMesh;
  66215. }, scene?: Nullable<Scene>): LinesMesh;
  66216. /**
  66217. * 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.
  66218. * * 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.
  66219. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66220. * * 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.
  66221. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  66222. * * 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
  66223. * * 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
  66224. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  66225. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66226. * * 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
  66227. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  66228. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66229. * @param name defines the name of the mesh
  66230. * @param options defines the options used to create the mesh
  66231. * @param scene defines the hosting scene
  66232. * @returns the extruded shape mesh
  66233. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66234. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66235. */
  66236. static ExtrudeShape(name: string, options: {
  66237. shape: Vector3[];
  66238. path: Vector3[];
  66239. scale?: number;
  66240. rotation?: number;
  66241. cap?: number;
  66242. updatable?: boolean;
  66243. sideOrientation?: number;
  66244. frontUVs?: Vector4;
  66245. backUVs?: Vector4;
  66246. instance?: Mesh;
  66247. invertUV?: boolean;
  66248. }, scene?: Nullable<Scene>): Mesh;
  66249. /**
  66250. * Creates an custom extruded shape mesh.
  66251. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  66252. * * 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.
  66253. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66254. * * 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
  66255. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  66256. * * 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
  66257. * * It must returns a float value that will be the scale value applied to the shape on each path point
  66258. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  66259. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  66260. * * 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
  66261. * * 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
  66262. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  66263. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66264. * * 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
  66265. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66266. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66267. * @param name defines the name of the mesh
  66268. * @param options defines the options used to create the mesh
  66269. * @param scene defines the hosting scene
  66270. * @returns the custom extruded shape mesh
  66271. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  66272. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66273. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66274. */
  66275. static ExtrudeShapeCustom(name: string, options: {
  66276. shape: Vector3[];
  66277. path: Vector3[];
  66278. scaleFunction?: any;
  66279. rotationFunction?: any;
  66280. ribbonCloseArray?: boolean;
  66281. ribbonClosePath?: boolean;
  66282. cap?: number;
  66283. updatable?: boolean;
  66284. sideOrientation?: number;
  66285. frontUVs?: Vector4;
  66286. backUVs?: Vector4;
  66287. instance?: Mesh;
  66288. invertUV?: boolean;
  66289. }, scene?: Nullable<Scene>): Mesh;
  66290. /**
  66291. * Creates lathe mesh.
  66292. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66293. * * 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
  66294. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66295. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66296. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66297. * * 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
  66298. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66299. * * 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
  66300. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66301. * * 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
  66302. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66303. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66304. * @param name defines the name of the mesh
  66305. * @param options defines the options used to create the mesh
  66306. * @param scene defines the hosting scene
  66307. * @returns the lathe mesh
  66308. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66309. */
  66310. static CreateLathe(name: string, options: {
  66311. shape: Vector3[];
  66312. radius?: number;
  66313. tessellation?: number;
  66314. clip?: number;
  66315. arc?: number;
  66316. closed?: boolean;
  66317. updatable?: boolean;
  66318. sideOrientation?: number;
  66319. frontUVs?: Vector4;
  66320. backUVs?: Vector4;
  66321. cap?: number;
  66322. invertUV?: boolean;
  66323. }, scene?: Nullable<Scene>): Mesh;
  66324. /**
  66325. * Creates a tiled plane mesh
  66326. * * You can set a limited pattern arrangement with the tiles
  66327. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66328. * * 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
  66329. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66330. * @param name defines the name of the mesh
  66331. * @param options defines the options used to create the mesh
  66332. * @param scene defines the hosting scene
  66333. * @returns the plane mesh
  66334. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66335. */
  66336. static CreateTiledPlane(name: string, options: {
  66337. pattern?: number;
  66338. tileSize?: number;
  66339. tileWidth?: number;
  66340. tileHeight?: number;
  66341. size?: number;
  66342. width?: number;
  66343. height?: number;
  66344. alignHorizontal?: number;
  66345. alignVertical?: number;
  66346. sideOrientation?: number;
  66347. frontUVs?: Vector4;
  66348. backUVs?: Vector4;
  66349. updatable?: boolean;
  66350. }, scene?: Nullable<Scene>): Mesh;
  66351. /**
  66352. * Creates a plane mesh
  66353. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  66354. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  66355. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  66356. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66357. * * 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
  66358. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66359. * @param name defines the name of the mesh
  66360. * @param options defines the options used to create the mesh
  66361. * @param scene defines the hosting scene
  66362. * @returns the plane mesh
  66363. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66364. */
  66365. static CreatePlane(name: string, options: {
  66366. size?: number;
  66367. width?: number;
  66368. height?: number;
  66369. sideOrientation?: number;
  66370. frontUVs?: Vector4;
  66371. backUVs?: Vector4;
  66372. updatable?: boolean;
  66373. sourcePlane?: Plane;
  66374. }, scene?: Nullable<Scene>): Mesh;
  66375. /**
  66376. * Creates a ground mesh
  66377. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  66378. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  66379. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66380. * @param name defines the name of the mesh
  66381. * @param options defines the options used to create the mesh
  66382. * @param scene defines the hosting scene
  66383. * @returns the ground mesh
  66384. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  66385. */
  66386. static CreateGround(name: string, options: {
  66387. width?: number;
  66388. height?: number;
  66389. subdivisions?: number;
  66390. subdivisionsX?: number;
  66391. subdivisionsY?: number;
  66392. updatable?: boolean;
  66393. }, scene?: Nullable<Scene>): Mesh;
  66394. /**
  66395. * Creates a tiled ground mesh
  66396. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  66397. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  66398. * * 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
  66399. * * 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
  66400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66401. * @param name defines the name of the mesh
  66402. * @param options defines the options used to create the mesh
  66403. * @param scene defines the hosting scene
  66404. * @returns the tiled ground mesh
  66405. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  66406. */
  66407. static CreateTiledGround(name: string, options: {
  66408. xmin: number;
  66409. zmin: number;
  66410. xmax: number;
  66411. zmax: number;
  66412. subdivisions?: {
  66413. w: number;
  66414. h: number;
  66415. };
  66416. precision?: {
  66417. w: number;
  66418. h: number;
  66419. };
  66420. updatable?: boolean;
  66421. }, scene?: Nullable<Scene>): Mesh;
  66422. /**
  66423. * Creates a ground mesh from a height map
  66424. * * The parameter `url` sets the URL of the height map image resource.
  66425. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  66426. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  66427. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  66428. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  66429. * * 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.
  66430. * * 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).
  66431. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  66432. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66433. * @param name defines the name of the mesh
  66434. * @param url defines the url to the height map
  66435. * @param options defines the options used to create the mesh
  66436. * @param scene defines the hosting scene
  66437. * @returns the ground mesh
  66438. * @see https://doc.babylonjs.com/babylon101/height_map
  66439. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  66440. */
  66441. static CreateGroundFromHeightMap(name: string, url: string, options: {
  66442. width?: number;
  66443. height?: number;
  66444. subdivisions?: number;
  66445. minHeight?: number;
  66446. maxHeight?: number;
  66447. colorFilter?: Color3;
  66448. alphaFilter?: number;
  66449. updatable?: boolean;
  66450. onReady?: (mesh: GroundMesh) => void;
  66451. }, scene?: Nullable<Scene>): GroundMesh;
  66452. /**
  66453. * Creates a polygon mesh
  66454. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66455. * * 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
  66456. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66457. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66458. * * 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)
  66459. * * Remember you can only change the shape positions, not their number when updating a polygon
  66460. * @param name defines the name of the mesh
  66461. * @param options defines the options used to create the mesh
  66462. * @param scene defines the hosting scene
  66463. * @param earcutInjection can be used to inject your own earcut reference
  66464. * @returns the polygon mesh
  66465. */
  66466. static CreatePolygon(name: string, options: {
  66467. shape: Vector3[];
  66468. holes?: Vector3[][];
  66469. depth?: number;
  66470. faceUV?: Vector4[];
  66471. faceColors?: Color4[];
  66472. updatable?: boolean;
  66473. sideOrientation?: number;
  66474. frontUVs?: Vector4;
  66475. backUVs?: Vector4;
  66476. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66477. /**
  66478. * Creates an extruded polygon mesh, with depth in the Y direction.
  66479. * * 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)
  66480. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66481. * @param name defines the name of the mesh
  66482. * @param options defines the options used to create the mesh
  66483. * @param scene defines the hosting scene
  66484. * @param earcutInjection can be used to inject your own earcut reference
  66485. * @returns the polygon mesh
  66486. */
  66487. static ExtrudePolygon(name: string, options: {
  66488. shape: Vector3[];
  66489. holes?: Vector3[][];
  66490. depth?: number;
  66491. faceUV?: Vector4[];
  66492. faceColors?: Color4[];
  66493. updatable?: boolean;
  66494. sideOrientation?: number;
  66495. frontUVs?: Vector4;
  66496. backUVs?: Vector4;
  66497. wrap?: boolean;
  66498. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66499. /**
  66500. * Creates a tube mesh.
  66501. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66502. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  66503. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  66504. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  66505. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  66506. * * 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)
  66507. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  66508. * * 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
  66509. * * 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
  66510. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66511. * * 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
  66512. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66514. * @param name defines the name of the mesh
  66515. * @param options defines the options used to create the mesh
  66516. * @param scene defines the hosting scene
  66517. * @returns the tube mesh
  66518. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66519. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  66520. */
  66521. static CreateTube(name: string, options: {
  66522. path: Vector3[];
  66523. radius?: number;
  66524. tessellation?: number;
  66525. radiusFunction?: {
  66526. (i: number, distance: number): number;
  66527. };
  66528. cap?: number;
  66529. arc?: number;
  66530. updatable?: boolean;
  66531. sideOrientation?: number;
  66532. frontUVs?: Vector4;
  66533. backUVs?: Vector4;
  66534. instance?: Mesh;
  66535. invertUV?: boolean;
  66536. }, scene?: Nullable<Scene>): Mesh;
  66537. /**
  66538. * Creates a polyhedron mesh
  66539. * * 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
  66540. * * The parameter `size` (positive float, default 1) sets the polygon size
  66541. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  66542. * * 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`
  66543. * * 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
  66544. * * 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)`)
  66545. * * 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
  66546. * * 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
  66547. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66548. * * 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
  66549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66550. * @param name defines the name of the mesh
  66551. * @param options defines the options used to create the mesh
  66552. * @param scene defines the hosting scene
  66553. * @returns the polyhedron mesh
  66554. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  66555. */
  66556. static CreatePolyhedron(name: string, options: {
  66557. type?: number;
  66558. size?: number;
  66559. sizeX?: number;
  66560. sizeY?: number;
  66561. sizeZ?: number;
  66562. custom?: any;
  66563. faceUV?: Vector4[];
  66564. faceColors?: Color4[];
  66565. flat?: boolean;
  66566. updatable?: boolean;
  66567. sideOrientation?: number;
  66568. frontUVs?: Vector4;
  66569. backUVs?: Vector4;
  66570. }, scene?: Nullable<Scene>): Mesh;
  66571. /**
  66572. * Creates a decal mesh.
  66573. * 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
  66574. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  66575. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  66576. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  66577. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  66578. * @param name defines the name of the mesh
  66579. * @param sourceMesh defines the mesh where the decal must be applied
  66580. * @param options defines the options used to create the mesh
  66581. * @param scene defines the hosting scene
  66582. * @returns the decal mesh
  66583. * @see https://doc.babylonjs.com/how_to/decals
  66584. */
  66585. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  66586. position?: Vector3;
  66587. normal?: Vector3;
  66588. size?: Vector3;
  66589. angle?: number;
  66590. }): Mesh;
  66591. /**
  66592. * Creates a Capsule Mesh
  66593. * @param name defines the name of the mesh.
  66594. * @param options the constructors options used to shape the mesh.
  66595. * @param scene defines the scene the mesh is scoped to.
  66596. * @returns the capsule mesh
  66597. * @see https://doc.babylonjs.com/how_to/capsule_shape
  66598. */
  66599. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  66600. }
  66601. }
  66602. declare module BABYLON {
  66603. /**
  66604. * A simplifier interface for future simplification implementations
  66605. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66606. */
  66607. export interface ISimplifier {
  66608. /**
  66609. * Simplification of a given mesh according to the given settings.
  66610. * Since this requires computation, it is assumed that the function runs async.
  66611. * @param settings The settings of the simplification, including quality and distance
  66612. * @param successCallback A callback that will be called after the mesh was simplified.
  66613. * @param errorCallback in case of an error, this callback will be called. optional.
  66614. */
  66615. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  66616. }
  66617. /**
  66618. * Expected simplification settings.
  66619. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  66620. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66621. */
  66622. export interface ISimplificationSettings {
  66623. /**
  66624. * Gets or sets the expected quality
  66625. */
  66626. quality: number;
  66627. /**
  66628. * Gets or sets the distance when this optimized version should be used
  66629. */
  66630. distance: number;
  66631. /**
  66632. * Gets an already optimized mesh
  66633. */
  66634. optimizeMesh?: boolean;
  66635. }
  66636. /**
  66637. * Class used to specify simplification options
  66638. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66639. */
  66640. export class SimplificationSettings implements ISimplificationSettings {
  66641. /** expected quality */
  66642. quality: number;
  66643. /** distance when this optimized version should be used */
  66644. distance: number;
  66645. /** already optimized mesh */
  66646. optimizeMesh?: boolean | undefined;
  66647. /**
  66648. * Creates a SimplificationSettings
  66649. * @param quality expected quality
  66650. * @param distance distance when this optimized version should be used
  66651. * @param optimizeMesh already optimized mesh
  66652. */
  66653. constructor(
  66654. /** expected quality */
  66655. quality: number,
  66656. /** distance when this optimized version should be used */
  66657. distance: number,
  66658. /** already optimized mesh */
  66659. optimizeMesh?: boolean | undefined);
  66660. }
  66661. /**
  66662. * Interface used to define a simplification task
  66663. */
  66664. export interface ISimplificationTask {
  66665. /**
  66666. * Array of settings
  66667. */
  66668. settings: Array<ISimplificationSettings>;
  66669. /**
  66670. * Simplification type
  66671. */
  66672. simplificationType: SimplificationType;
  66673. /**
  66674. * Mesh to simplify
  66675. */
  66676. mesh: Mesh;
  66677. /**
  66678. * Callback called on success
  66679. */
  66680. successCallback?: () => void;
  66681. /**
  66682. * Defines if parallel processing can be used
  66683. */
  66684. parallelProcessing: boolean;
  66685. }
  66686. /**
  66687. * Queue used to order the simplification tasks
  66688. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66689. */
  66690. export class SimplificationQueue {
  66691. private _simplificationArray;
  66692. /**
  66693. * Gets a boolean indicating that the process is still running
  66694. */
  66695. running: boolean;
  66696. /**
  66697. * Creates a new queue
  66698. */
  66699. constructor();
  66700. /**
  66701. * Adds a new simplification task
  66702. * @param task defines a task to add
  66703. */
  66704. addTask(task: ISimplificationTask): void;
  66705. /**
  66706. * Execute next task
  66707. */
  66708. executeNext(): void;
  66709. /**
  66710. * Execute a simplification task
  66711. * @param task defines the task to run
  66712. */
  66713. runSimplification(task: ISimplificationTask): void;
  66714. private getSimplifier;
  66715. }
  66716. /**
  66717. * The implemented types of simplification
  66718. * At the moment only Quadratic Error Decimation is implemented
  66719. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66720. */
  66721. export enum SimplificationType {
  66722. /** Quadratic error decimation */
  66723. QUADRATIC = 0
  66724. }
  66725. /**
  66726. * An implementation of the Quadratic Error simplification algorithm.
  66727. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  66728. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  66729. * @author RaananW
  66730. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66731. */
  66732. export class QuadraticErrorSimplification implements ISimplifier {
  66733. private _mesh;
  66734. private triangles;
  66735. private vertices;
  66736. private references;
  66737. private _reconstructedMesh;
  66738. /** Gets or sets the number pf sync interations */
  66739. syncIterations: number;
  66740. /** Gets or sets the aggressiveness of the simplifier */
  66741. aggressiveness: number;
  66742. /** Gets or sets the number of allowed iterations for decimation */
  66743. decimationIterations: number;
  66744. /** Gets or sets the espilon to use for bounding box computation */
  66745. boundingBoxEpsilon: number;
  66746. /**
  66747. * Creates a new QuadraticErrorSimplification
  66748. * @param _mesh defines the target mesh
  66749. */
  66750. constructor(_mesh: Mesh);
  66751. /**
  66752. * Simplification of a given mesh according to the given settings.
  66753. * Since this requires computation, it is assumed that the function runs async.
  66754. * @param settings The settings of the simplification, including quality and distance
  66755. * @param successCallback A callback that will be called after the mesh was simplified.
  66756. */
  66757. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  66758. private runDecimation;
  66759. private initWithMesh;
  66760. private init;
  66761. private reconstructMesh;
  66762. private initDecimatedMesh;
  66763. private isFlipped;
  66764. private updateTriangles;
  66765. private identifyBorder;
  66766. private updateMesh;
  66767. private vertexError;
  66768. private calculateError;
  66769. }
  66770. }
  66771. declare module BABYLON {
  66772. interface Scene {
  66773. /** @hidden (Backing field) */
  66774. _simplificationQueue: SimplificationQueue;
  66775. /**
  66776. * Gets or sets the simplification queue attached to the scene
  66777. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66778. */
  66779. simplificationQueue: SimplificationQueue;
  66780. }
  66781. interface Mesh {
  66782. /**
  66783. * Simplify the mesh according to the given array of settings.
  66784. * Function will return immediately and will simplify async
  66785. * @param settings a collection of simplification settings
  66786. * @param parallelProcessing should all levels calculate parallel or one after the other
  66787. * @param simplificationType the type of simplification to run
  66788. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  66789. * @returns the current mesh
  66790. */
  66791. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  66792. }
  66793. /**
  66794. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  66795. * created in a scene
  66796. */
  66797. export class SimplicationQueueSceneComponent implements ISceneComponent {
  66798. /**
  66799. * The component name helpfull to identify the component in the list of scene components.
  66800. */
  66801. readonly name: string;
  66802. /**
  66803. * The scene the component belongs to.
  66804. */
  66805. scene: Scene;
  66806. /**
  66807. * Creates a new instance of the component for the given scene
  66808. * @param scene Defines the scene to register the component in
  66809. */
  66810. constructor(scene: Scene);
  66811. /**
  66812. * Registers the component in a given scene
  66813. */
  66814. register(): void;
  66815. /**
  66816. * Rebuilds the elements related to this component in case of
  66817. * context lost for instance.
  66818. */
  66819. rebuild(): void;
  66820. /**
  66821. * Disposes the component and the associated ressources
  66822. */
  66823. dispose(): void;
  66824. private _beforeCameraUpdate;
  66825. }
  66826. }
  66827. declare module BABYLON {
  66828. interface Mesh {
  66829. /**
  66830. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  66831. */
  66832. thinInstanceEnablePicking: boolean;
  66833. /**
  66834. * Creates a new thin instance
  66835. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  66836. * @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
  66837. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  66838. */
  66839. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  66840. /**
  66841. * Adds the transformation (matrix) of the current mesh as a thin instance
  66842. * @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
  66843. * @returns the thin instance index number
  66844. */
  66845. thinInstanceAddSelf(refresh: boolean): number;
  66846. /**
  66847. * Registers a custom attribute to be used with thin instances
  66848. * @param kind name of the attribute
  66849. * @param stride size in floats of the attribute
  66850. */
  66851. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  66852. /**
  66853. * Sets the matrix of a thin instance
  66854. * @param index index of the thin instance
  66855. * @param matrix matrix to set
  66856. * @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
  66857. */
  66858. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  66859. /**
  66860. * Sets the value of a custom attribute for a thin instance
  66861. * @param kind name of the attribute
  66862. * @param index index of the thin instance
  66863. * @param value value to set
  66864. * @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
  66865. */
  66866. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  66867. /**
  66868. * 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.
  66869. */
  66870. thinInstanceCount: number;
  66871. /**
  66872. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  66873. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  66874. * @param buffer buffer to set
  66875. * @param stride size in floats of each value of the buffer
  66876. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  66877. */
  66878. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  66879. /**
  66880. * Gets the list of world matrices
  66881. * @return an array containing all the world matrices from the thin instances
  66882. */
  66883. thinInstanceGetWorldMatrices(): Matrix[];
  66884. /**
  66885. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  66886. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  66887. */
  66888. thinInstanceBufferUpdated(kind: string): void;
  66889. /**
  66890. * Applies a partial update to a buffer directly on the GPU
  66891. * 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
  66892. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  66893. * @param data the data to set in the GPU buffer
  66894. * @param offset the offset in the GPU buffer where to update the data
  66895. */
  66896. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  66897. /**
  66898. * Refreshes the bounding info, taking into account all the thin instances defined
  66899. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  66900. */
  66901. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  66902. /** @hidden */
  66903. _thinInstanceInitializeUserStorage(): void;
  66904. /** @hidden */
  66905. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  66906. /** @hidden */
  66907. _userThinInstanceBuffersStorage: {
  66908. data: {
  66909. [key: string]: Float32Array;
  66910. };
  66911. sizes: {
  66912. [key: string]: number;
  66913. };
  66914. vertexBuffers: {
  66915. [key: string]: Nullable<VertexBuffer>;
  66916. };
  66917. strides: {
  66918. [key: string]: number;
  66919. };
  66920. };
  66921. }
  66922. }
  66923. declare module BABYLON {
  66924. /**
  66925. * Navigation plugin interface to add navigation constrained by a navigation mesh
  66926. */
  66927. export interface INavigationEnginePlugin {
  66928. /**
  66929. * plugin name
  66930. */
  66931. name: string;
  66932. /**
  66933. * Creates a navigation mesh
  66934. * @param meshes array of all the geometry used to compute the navigatio mesh
  66935. * @param parameters bunch of parameters used to filter geometry
  66936. */
  66937. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  66938. /**
  66939. * Create a navigation mesh debug mesh
  66940. * @param scene is where the mesh will be added
  66941. * @returns debug display mesh
  66942. */
  66943. createDebugNavMesh(scene: Scene): Mesh;
  66944. /**
  66945. * Get a navigation mesh constrained position, closest to the parameter position
  66946. * @param position world position
  66947. * @returns the closest point to position constrained by the navigation mesh
  66948. */
  66949. getClosestPoint(position: Vector3): Vector3;
  66950. /**
  66951. * Get a navigation mesh constrained position, closest to the parameter position
  66952. * @param position world position
  66953. * @param result output the closest point to position constrained by the navigation mesh
  66954. */
  66955. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66956. /**
  66957. * Get a navigation mesh constrained position, within a particular radius
  66958. * @param position world position
  66959. * @param maxRadius the maximum distance to the constrained world position
  66960. * @returns the closest point to position constrained by the navigation mesh
  66961. */
  66962. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  66963. /**
  66964. * Get a navigation mesh constrained position, within a particular radius
  66965. * @param position world position
  66966. * @param maxRadius the maximum distance to the constrained world position
  66967. * @param result output the closest point to position constrained by the navigation mesh
  66968. */
  66969. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  66970. /**
  66971. * Compute the final position from a segment made of destination-position
  66972. * @param position world position
  66973. * @param destination world position
  66974. * @returns the resulting point along the navmesh
  66975. */
  66976. moveAlong(position: Vector3, destination: Vector3): Vector3;
  66977. /**
  66978. * Compute the final position from a segment made of destination-position
  66979. * @param position world position
  66980. * @param destination world position
  66981. * @param result output the resulting point along the navmesh
  66982. */
  66983. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  66984. /**
  66985. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  66986. * @param start world position
  66987. * @param end world position
  66988. * @returns array containing world position composing the path
  66989. */
  66990. computePath(start: Vector3, end: Vector3): Vector3[];
  66991. /**
  66992. * If this plugin is supported
  66993. * @returns true if plugin is supported
  66994. */
  66995. isSupported(): boolean;
  66996. /**
  66997. * Create a new Crowd so you can add agents
  66998. * @param maxAgents the maximum agent count in the crowd
  66999. * @param maxAgentRadius the maximum radius an agent can have
  67000. * @param scene to attach the crowd to
  67001. * @returns the crowd you can add agents to
  67002. */
  67003. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67004. /**
  67005. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67006. * The queries will try to find a solution within those bounds
  67007. * default is (1,1,1)
  67008. * @param extent x,y,z value that define the extent around the queries point of reference
  67009. */
  67010. setDefaultQueryExtent(extent: Vector3): void;
  67011. /**
  67012. * Get the Bounding box extent specified by setDefaultQueryExtent
  67013. * @returns the box extent values
  67014. */
  67015. getDefaultQueryExtent(): Vector3;
  67016. /**
  67017. * build the navmesh from a previously saved state using getNavmeshData
  67018. * @param data the Uint8Array returned by getNavmeshData
  67019. */
  67020. buildFromNavmeshData(data: Uint8Array): void;
  67021. /**
  67022. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67023. * @returns data the Uint8Array that can be saved and reused
  67024. */
  67025. getNavmeshData(): Uint8Array;
  67026. /**
  67027. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67028. * @param result output the box extent values
  67029. */
  67030. getDefaultQueryExtentToRef(result: Vector3): void;
  67031. /**
  67032. * Release all resources
  67033. */
  67034. dispose(): void;
  67035. }
  67036. /**
  67037. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  67038. */
  67039. export interface ICrowd {
  67040. /**
  67041. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67042. * You can attach anything to that node. The node position is updated in the scene update tick.
  67043. * @param pos world position that will be constrained by the navigation mesh
  67044. * @param parameters agent parameters
  67045. * @param transform hooked to the agent that will be update by the scene
  67046. * @returns agent index
  67047. */
  67048. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67049. /**
  67050. * Returns the agent position in world space
  67051. * @param index agent index returned by addAgent
  67052. * @returns world space position
  67053. */
  67054. getAgentPosition(index: number): Vector3;
  67055. /**
  67056. * Gets the agent position result in world space
  67057. * @param index agent index returned by addAgent
  67058. * @param result output world space position
  67059. */
  67060. getAgentPositionToRef(index: number, result: Vector3): void;
  67061. /**
  67062. * Gets the agent velocity in world space
  67063. * @param index agent index returned by addAgent
  67064. * @returns world space velocity
  67065. */
  67066. getAgentVelocity(index: number): Vector3;
  67067. /**
  67068. * Gets the agent velocity result in world space
  67069. * @param index agent index returned by addAgent
  67070. * @param result output world space velocity
  67071. */
  67072. getAgentVelocityToRef(index: number, result: Vector3): void;
  67073. /**
  67074. * remove a particular agent previously created
  67075. * @param index agent index returned by addAgent
  67076. */
  67077. removeAgent(index: number): void;
  67078. /**
  67079. * get the list of all agents attached to this crowd
  67080. * @returns list of agent indices
  67081. */
  67082. getAgents(): number[];
  67083. /**
  67084. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67085. * @param deltaTime in seconds
  67086. */
  67087. update(deltaTime: number): void;
  67088. /**
  67089. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67090. * @param index agent index returned by addAgent
  67091. * @param destination targeted world position
  67092. */
  67093. agentGoto(index: number, destination: Vector3): void;
  67094. /**
  67095. * Teleport the agent to a new position
  67096. * @param index agent index returned by addAgent
  67097. * @param destination targeted world position
  67098. */
  67099. agentTeleport(index: number, destination: Vector3): void;
  67100. /**
  67101. * Update agent parameters
  67102. * @param index agent index returned by addAgent
  67103. * @param parameters agent parameters
  67104. */
  67105. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67106. /**
  67107. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67108. * The queries will try to find a solution within those bounds
  67109. * default is (1,1,1)
  67110. * @param extent x,y,z value that define the extent around the queries point of reference
  67111. */
  67112. setDefaultQueryExtent(extent: Vector3): void;
  67113. /**
  67114. * Get the Bounding box extent specified by setDefaultQueryExtent
  67115. * @returns the box extent values
  67116. */
  67117. getDefaultQueryExtent(): Vector3;
  67118. /**
  67119. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67120. * @param result output the box extent values
  67121. */
  67122. getDefaultQueryExtentToRef(result: Vector3): void;
  67123. /**
  67124. * Release all resources
  67125. */
  67126. dispose(): void;
  67127. }
  67128. /**
  67129. * Configures an agent
  67130. */
  67131. export interface IAgentParameters {
  67132. /**
  67133. * Agent radius. [Limit: >= 0]
  67134. */
  67135. radius: number;
  67136. /**
  67137. * Agent height. [Limit: > 0]
  67138. */
  67139. height: number;
  67140. /**
  67141. * Maximum allowed acceleration. [Limit: >= 0]
  67142. */
  67143. maxAcceleration: number;
  67144. /**
  67145. * Maximum allowed speed. [Limit: >= 0]
  67146. */
  67147. maxSpeed: number;
  67148. /**
  67149. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  67150. */
  67151. collisionQueryRange: number;
  67152. /**
  67153. * The path visibility optimization range. [Limit: > 0]
  67154. */
  67155. pathOptimizationRange: number;
  67156. /**
  67157. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  67158. */
  67159. separationWeight: number;
  67160. }
  67161. /**
  67162. * Configures the navigation mesh creation
  67163. */
  67164. export interface INavMeshParameters {
  67165. /**
  67166. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  67167. */
  67168. cs: number;
  67169. /**
  67170. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  67171. */
  67172. ch: number;
  67173. /**
  67174. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  67175. */
  67176. walkableSlopeAngle: number;
  67177. /**
  67178. * Minimum floor to 'ceiling' height that will still allow the floor area to
  67179. * be considered walkable. [Limit: >= 3] [Units: vx]
  67180. */
  67181. walkableHeight: number;
  67182. /**
  67183. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  67184. */
  67185. walkableClimb: number;
  67186. /**
  67187. * The distance to erode/shrink the walkable area of the heightfield away from
  67188. * obstructions. [Limit: >=0] [Units: vx]
  67189. */
  67190. walkableRadius: number;
  67191. /**
  67192. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  67193. */
  67194. maxEdgeLen: number;
  67195. /**
  67196. * The maximum distance a simplfied contour's border edges should deviate
  67197. * the original raw contour. [Limit: >=0] [Units: vx]
  67198. */
  67199. maxSimplificationError: number;
  67200. /**
  67201. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  67202. */
  67203. minRegionArea: number;
  67204. /**
  67205. * Any regions with a span count smaller than this value will, if possible,
  67206. * be merged with larger regions. [Limit: >=0] [Units: vx]
  67207. */
  67208. mergeRegionArea: number;
  67209. /**
  67210. * The maximum number of vertices allowed for polygons generated during the
  67211. * contour to polygon conversion process. [Limit: >= 3]
  67212. */
  67213. maxVertsPerPoly: number;
  67214. /**
  67215. * Sets the sampling distance to use when generating the detail mesh.
  67216. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  67217. */
  67218. detailSampleDist: number;
  67219. /**
  67220. * The maximum distance the detail mesh surface should deviate from heightfield
  67221. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  67222. */
  67223. detailSampleMaxError: number;
  67224. }
  67225. }
  67226. declare module BABYLON {
  67227. /**
  67228. * RecastJS navigation plugin
  67229. */
  67230. export class RecastJSPlugin implements INavigationEnginePlugin {
  67231. /**
  67232. * Reference to the Recast library
  67233. */
  67234. bjsRECAST: any;
  67235. /**
  67236. * plugin name
  67237. */
  67238. name: string;
  67239. /**
  67240. * the first navmesh created. We might extend this to support multiple navmeshes
  67241. */
  67242. navMesh: any;
  67243. /**
  67244. * Initializes the recastJS plugin
  67245. * @param recastInjection can be used to inject your own recast reference
  67246. */
  67247. constructor(recastInjection?: any);
  67248. /**
  67249. * Creates a navigation mesh
  67250. * @param meshes array of all the geometry used to compute the navigatio mesh
  67251. * @param parameters bunch of parameters used to filter geometry
  67252. */
  67253. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  67254. /**
  67255. * Create a navigation mesh debug mesh
  67256. * @param scene is where the mesh will be added
  67257. * @returns debug display mesh
  67258. */
  67259. createDebugNavMesh(scene: Scene): Mesh;
  67260. /**
  67261. * Get a navigation mesh constrained position, closest to the parameter position
  67262. * @param position world position
  67263. * @returns the closest point to position constrained by the navigation mesh
  67264. */
  67265. getClosestPoint(position: Vector3): Vector3;
  67266. /**
  67267. * Get a navigation mesh constrained position, closest to the parameter position
  67268. * @param position world position
  67269. * @param result output the closest point to position constrained by the navigation mesh
  67270. */
  67271. getClosestPointToRef(position: Vector3, result: Vector3): void;
  67272. /**
  67273. * Get a navigation mesh constrained position, within a particular radius
  67274. * @param position world position
  67275. * @param maxRadius the maximum distance to the constrained world position
  67276. * @returns the closest point to position constrained by the navigation mesh
  67277. */
  67278. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  67279. /**
  67280. * Get a navigation mesh constrained position, within a particular radius
  67281. * @param position world position
  67282. * @param maxRadius the maximum distance to the constrained world position
  67283. * @param result output the closest point to position constrained by the navigation mesh
  67284. */
  67285. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67286. /**
  67287. * Compute the final position from a segment made of destination-position
  67288. * @param position world position
  67289. * @param destination world position
  67290. * @returns the resulting point along the navmesh
  67291. */
  67292. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67293. /**
  67294. * Compute the final position from a segment made of destination-position
  67295. * @param position world position
  67296. * @param destination world position
  67297. * @param result output the resulting point along the navmesh
  67298. */
  67299. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67300. /**
  67301. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67302. * @param start world position
  67303. * @param end world position
  67304. * @returns array containing world position composing the path
  67305. */
  67306. computePath(start: Vector3, end: Vector3): Vector3[];
  67307. /**
  67308. * Create a new Crowd so you can add agents
  67309. * @param maxAgents the maximum agent count in the crowd
  67310. * @param maxAgentRadius the maximum radius an agent can have
  67311. * @param scene to attach the crowd to
  67312. * @returns the crowd you can add agents to
  67313. */
  67314. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67315. /**
  67316. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67317. * The queries will try to find a solution within those bounds
  67318. * default is (1,1,1)
  67319. * @param extent x,y,z value that define the extent around the queries point of reference
  67320. */
  67321. setDefaultQueryExtent(extent: Vector3): void;
  67322. /**
  67323. * Get the Bounding box extent specified by setDefaultQueryExtent
  67324. * @returns the box extent values
  67325. */
  67326. getDefaultQueryExtent(): Vector3;
  67327. /**
  67328. * build the navmesh from a previously saved state using getNavmeshData
  67329. * @param data the Uint8Array returned by getNavmeshData
  67330. */
  67331. buildFromNavmeshData(data: Uint8Array): void;
  67332. /**
  67333. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67334. * @returns data the Uint8Array that can be saved and reused
  67335. */
  67336. getNavmeshData(): Uint8Array;
  67337. /**
  67338. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67339. * @param result output the box extent values
  67340. */
  67341. getDefaultQueryExtentToRef(result: Vector3): void;
  67342. /**
  67343. * Disposes
  67344. */
  67345. dispose(): void;
  67346. /**
  67347. * If this plugin is supported
  67348. * @returns true if plugin is supported
  67349. */
  67350. isSupported(): boolean;
  67351. }
  67352. /**
  67353. * Recast detour crowd implementation
  67354. */
  67355. export class RecastJSCrowd implements ICrowd {
  67356. /**
  67357. * Recast/detour plugin
  67358. */
  67359. bjsRECASTPlugin: RecastJSPlugin;
  67360. /**
  67361. * Link to the detour crowd
  67362. */
  67363. recastCrowd: any;
  67364. /**
  67365. * One transform per agent
  67366. */
  67367. transforms: TransformNode[];
  67368. /**
  67369. * All agents created
  67370. */
  67371. agents: number[];
  67372. /**
  67373. * Link to the scene is kept to unregister the crowd from the scene
  67374. */
  67375. private _scene;
  67376. /**
  67377. * Observer for crowd updates
  67378. */
  67379. private _onBeforeAnimationsObserver;
  67380. /**
  67381. * Constructor
  67382. * @param plugin recastJS plugin
  67383. * @param maxAgents the maximum agent count in the crowd
  67384. * @param maxAgentRadius the maximum radius an agent can have
  67385. * @param scene to attach the crowd to
  67386. * @returns the crowd you can add agents to
  67387. */
  67388. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  67389. /**
  67390. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67391. * You can attach anything to that node. The node position is updated in the scene update tick.
  67392. * @param pos world position that will be constrained by the navigation mesh
  67393. * @param parameters agent parameters
  67394. * @param transform hooked to the agent that will be update by the scene
  67395. * @returns agent index
  67396. */
  67397. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67398. /**
  67399. * Returns the agent position in world space
  67400. * @param index agent index returned by addAgent
  67401. * @returns world space position
  67402. */
  67403. getAgentPosition(index: number): Vector3;
  67404. /**
  67405. * Returns the agent position result in world space
  67406. * @param index agent index returned by addAgent
  67407. * @param result output world space position
  67408. */
  67409. getAgentPositionToRef(index: number, result: Vector3): void;
  67410. /**
  67411. * Returns the agent velocity in world space
  67412. * @param index agent index returned by addAgent
  67413. * @returns world space velocity
  67414. */
  67415. getAgentVelocity(index: number): Vector3;
  67416. /**
  67417. * Returns the agent velocity result in world space
  67418. * @param index agent index returned by addAgent
  67419. * @param result output world space velocity
  67420. */
  67421. getAgentVelocityToRef(index: number, result: Vector3): void;
  67422. /**
  67423. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67424. * @param index agent index returned by addAgent
  67425. * @param destination targeted world position
  67426. */
  67427. agentGoto(index: number, destination: Vector3): void;
  67428. /**
  67429. * Teleport the agent to a new position
  67430. * @param index agent index returned by addAgent
  67431. * @param destination targeted world position
  67432. */
  67433. agentTeleport(index: number, destination: Vector3): void;
  67434. /**
  67435. * Update agent parameters
  67436. * @param index agent index returned by addAgent
  67437. * @param parameters agent parameters
  67438. */
  67439. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67440. /**
  67441. * remove a particular agent previously created
  67442. * @param index agent index returned by addAgent
  67443. */
  67444. removeAgent(index: number): void;
  67445. /**
  67446. * get the list of all agents attached to this crowd
  67447. * @returns list of agent indices
  67448. */
  67449. getAgents(): number[];
  67450. /**
  67451. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67452. * @param deltaTime in seconds
  67453. */
  67454. update(deltaTime: number): void;
  67455. /**
  67456. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67457. * The queries will try to find a solution within those bounds
  67458. * default is (1,1,1)
  67459. * @param extent x,y,z value that define the extent around the queries point of reference
  67460. */
  67461. setDefaultQueryExtent(extent: Vector3): void;
  67462. /**
  67463. * Get the Bounding box extent specified by setDefaultQueryExtent
  67464. * @returns the box extent values
  67465. */
  67466. getDefaultQueryExtent(): Vector3;
  67467. /**
  67468. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67469. * @param result output the box extent values
  67470. */
  67471. getDefaultQueryExtentToRef(result: Vector3): void;
  67472. /**
  67473. * Release all resources
  67474. */
  67475. dispose(): void;
  67476. }
  67477. }
  67478. declare module BABYLON {
  67479. /**
  67480. * Class used to enable access to IndexedDB
  67481. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  67482. */
  67483. export class Database implements IOfflineProvider {
  67484. private _callbackManifestChecked;
  67485. private _currentSceneUrl;
  67486. private _db;
  67487. private _enableSceneOffline;
  67488. private _enableTexturesOffline;
  67489. private _manifestVersionFound;
  67490. private _mustUpdateRessources;
  67491. private _hasReachedQuota;
  67492. private _isSupported;
  67493. private _idbFactory;
  67494. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  67495. private static IsUASupportingBlobStorage;
  67496. /**
  67497. * Gets a boolean indicating if Database storate is enabled (off by default)
  67498. */
  67499. static IDBStorageEnabled: boolean;
  67500. /**
  67501. * Gets a boolean indicating if scene must be saved in the database
  67502. */
  67503. get enableSceneOffline(): boolean;
  67504. /**
  67505. * Gets a boolean indicating if textures must be saved in the database
  67506. */
  67507. get enableTexturesOffline(): boolean;
  67508. /**
  67509. * Creates a new Database
  67510. * @param urlToScene defines the url to load the scene
  67511. * @param callbackManifestChecked defines the callback to use when manifest is checked
  67512. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  67513. */
  67514. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  67515. private static _ParseURL;
  67516. private static _ReturnFullUrlLocation;
  67517. private _checkManifestFile;
  67518. /**
  67519. * Open the database and make it available
  67520. * @param successCallback defines the callback to call on success
  67521. * @param errorCallback defines the callback to call on error
  67522. */
  67523. open(successCallback: () => void, errorCallback: () => void): void;
  67524. /**
  67525. * Loads an image from the database
  67526. * @param url defines the url to load from
  67527. * @param image defines the target DOM image
  67528. */
  67529. loadImage(url: string, image: HTMLImageElement): void;
  67530. private _loadImageFromDBAsync;
  67531. private _saveImageIntoDBAsync;
  67532. private _checkVersionFromDB;
  67533. private _loadVersionFromDBAsync;
  67534. private _saveVersionIntoDBAsync;
  67535. /**
  67536. * Loads a file from database
  67537. * @param url defines the URL to load from
  67538. * @param sceneLoaded defines a callback to call on success
  67539. * @param progressCallBack defines a callback to call when progress changed
  67540. * @param errorCallback defines a callback to call on error
  67541. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  67542. */
  67543. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  67544. private _loadFileAsync;
  67545. private _saveFileAsync;
  67546. /**
  67547. * Validates if xhr data is correct
  67548. * @param xhr defines the request to validate
  67549. * @param dataType defines the expected data type
  67550. * @returns true if data is correct
  67551. */
  67552. private static _ValidateXHRData;
  67553. }
  67554. }
  67555. declare module BABYLON {
  67556. /** @hidden */
  67557. export var gpuUpdateParticlesPixelShader: {
  67558. name: string;
  67559. shader: string;
  67560. };
  67561. }
  67562. declare module BABYLON {
  67563. /** @hidden */
  67564. export var gpuUpdateParticlesVertexShader: {
  67565. name: string;
  67566. shader: string;
  67567. };
  67568. }
  67569. declare module BABYLON {
  67570. /** @hidden */
  67571. export var clipPlaneFragmentDeclaration2: {
  67572. name: string;
  67573. shader: string;
  67574. };
  67575. }
  67576. declare module BABYLON {
  67577. /** @hidden */
  67578. export var gpuRenderParticlesPixelShader: {
  67579. name: string;
  67580. shader: string;
  67581. };
  67582. }
  67583. declare module BABYLON {
  67584. /** @hidden */
  67585. export var clipPlaneVertexDeclaration2: {
  67586. name: string;
  67587. shader: string;
  67588. };
  67589. }
  67590. declare module BABYLON {
  67591. /** @hidden */
  67592. export var gpuRenderParticlesVertexShader: {
  67593. name: string;
  67594. shader: string;
  67595. };
  67596. }
  67597. declare module BABYLON {
  67598. /**
  67599. * This represents a GPU particle system in Babylon
  67600. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  67601. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  67602. */
  67603. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  67604. /**
  67605. * The layer mask we are rendering the particles through.
  67606. */
  67607. layerMask: number;
  67608. private _capacity;
  67609. private _activeCount;
  67610. private _currentActiveCount;
  67611. private _accumulatedCount;
  67612. private _renderEffect;
  67613. private _updateEffect;
  67614. private _buffer0;
  67615. private _buffer1;
  67616. private _spriteBuffer;
  67617. private _updateVAO;
  67618. private _renderVAO;
  67619. private _targetIndex;
  67620. private _sourceBuffer;
  67621. private _targetBuffer;
  67622. private _currentRenderId;
  67623. private _started;
  67624. private _stopped;
  67625. private _timeDelta;
  67626. private _randomTexture;
  67627. private _randomTexture2;
  67628. private _attributesStrideSize;
  67629. private _updateEffectOptions;
  67630. private _randomTextureSize;
  67631. private _actualFrame;
  67632. private _customEffect;
  67633. private readonly _rawTextureWidth;
  67634. /**
  67635. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  67636. */
  67637. static get IsSupported(): boolean;
  67638. /**
  67639. * An event triggered when the system is disposed.
  67640. */
  67641. onDisposeObservable: Observable<IParticleSystem>;
  67642. /**
  67643. * Gets the maximum number of particles active at the same time.
  67644. * @returns The max number of active particles.
  67645. */
  67646. getCapacity(): number;
  67647. /**
  67648. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  67649. * to override the particles.
  67650. */
  67651. forceDepthWrite: boolean;
  67652. /**
  67653. * Gets or set the number of active particles
  67654. */
  67655. get activeParticleCount(): number;
  67656. set activeParticleCount(value: number);
  67657. private _preWarmDone;
  67658. /**
  67659. * Specifies if the particles are updated in emitter local space or world space.
  67660. */
  67661. isLocal: boolean;
  67662. /** Gets or sets a matrix to use to compute projection */
  67663. defaultProjectionMatrix: Matrix;
  67664. /**
  67665. * Is this system ready to be used/rendered
  67666. * @return true if the system is ready
  67667. */
  67668. isReady(): boolean;
  67669. /**
  67670. * Gets if the system has been started. (Note: this will still be true after stop is called)
  67671. * @returns True if it has been started, otherwise false.
  67672. */
  67673. isStarted(): boolean;
  67674. /**
  67675. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  67676. * @returns True if it has been stopped, otherwise false.
  67677. */
  67678. isStopped(): boolean;
  67679. /**
  67680. * Gets a boolean indicating that the system is stopping
  67681. * @returns true if the system is currently stopping
  67682. */
  67683. isStopping(): boolean;
  67684. /**
  67685. * Gets the number of particles active at the same time.
  67686. * @returns The number of active particles.
  67687. */
  67688. getActiveCount(): number;
  67689. /**
  67690. * Starts the particle system and begins to emit
  67691. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  67692. */
  67693. start(delay?: number): void;
  67694. /**
  67695. * Stops the particle system.
  67696. */
  67697. stop(): void;
  67698. /**
  67699. * Remove all active particles
  67700. */
  67701. reset(): void;
  67702. /**
  67703. * Returns the string "GPUParticleSystem"
  67704. * @returns a string containing the class name
  67705. */
  67706. getClassName(): string;
  67707. /**
  67708. * Gets the custom effect used to render the particles
  67709. * @param blendMode Blend mode for which the effect should be retrieved
  67710. * @returns The effect
  67711. */
  67712. getCustomEffect(blendMode?: number): Nullable<Effect>;
  67713. /**
  67714. * Sets the custom effect used to render the particles
  67715. * @param effect The effect to set
  67716. * @param blendMode Blend mode for which the effect should be set
  67717. */
  67718. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  67719. /** @hidden */
  67720. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  67721. /**
  67722. * Observable that will be called just before the particles are drawn
  67723. */
  67724. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  67725. /**
  67726. * Gets the name of the particle vertex shader
  67727. */
  67728. get vertexShaderName(): string;
  67729. private _colorGradientsTexture;
  67730. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  67731. /**
  67732. * Adds a new color gradient
  67733. * @param gradient defines the gradient to use (between 0 and 1)
  67734. * @param color1 defines the color to affect to the specified gradient
  67735. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  67736. * @returns the current particle system
  67737. */
  67738. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  67739. private _refreshColorGradient;
  67740. /** Force the system to rebuild all gradients that need to be resync */
  67741. forceRefreshGradients(): void;
  67742. /**
  67743. * Remove a specific color gradient
  67744. * @param gradient defines the gradient to remove
  67745. * @returns the current particle system
  67746. */
  67747. removeColorGradient(gradient: number): GPUParticleSystem;
  67748. private _angularSpeedGradientsTexture;
  67749. private _sizeGradientsTexture;
  67750. private _velocityGradientsTexture;
  67751. private _limitVelocityGradientsTexture;
  67752. private _dragGradientsTexture;
  67753. private _addFactorGradient;
  67754. /**
  67755. * Adds a new size gradient
  67756. * @param gradient defines the gradient to use (between 0 and 1)
  67757. * @param factor defines the size factor to affect to the specified gradient
  67758. * @returns the current particle system
  67759. */
  67760. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  67761. /**
  67762. * Remove a specific size gradient
  67763. * @param gradient defines the gradient to remove
  67764. * @returns the current particle system
  67765. */
  67766. removeSizeGradient(gradient: number): GPUParticleSystem;
  67767. private _refreshFactorGradient;
  67768. /**
  67769. * Adds a new angular speed gradient
  67770. * @param gradient defines the gradient to use (between 0 and 1)
  67771. * @param factor defines the angular speed to affect to the specified gradient
  67772. * @returns the current particle system
  67773. */
  67774. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  67775. /**
  67776. * Remove a specific angular speed gradient
  67777. * @param gradient defines the gradient to remove
  67778. * @returns the current particle system
  67779. */
  67780. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  67781. /**
  67782. * Adds a new velocity gradient
  67783. * @param gradient defines the gradient to use (between 0 and 1)
  67784. * @param factor defines the velocity to affect to the specified gradient
  67785. * @returns the current particle system
  67786. */
  67787. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67788. /**
  67789. * Remove a specific velocity gradient
  67790. * @param gradient defines the gradient to remove
  67791. * @returns the current particle system
  67792. */
  67793. removeVelocityGradient(gradient: number): GPUParticleSystem;
  67794. /**
  67795. * Adds a new limit velocity gradient
  67796. * @param gradient defines the gradient to use (between 0 and 1)
  67797. * @param factor defines the limit velocity value to affect to the specified gradient
  67798. * @returns the current particle system
  67799. */
  67800. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67801. /**
  67802. * Remove a specific limit velocity gradient
  67803. * @param gradient defines the gradient to remove
  67804. * @returns the current particle system
  67805. */
  67806. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  67807. /**
  67808. * Adds a new drag gradient
  67809. * @param gradient defines the gradient to use (between 0 and 1)
  67810. * @param factor defines the drag value to affect to the specified gradient
  67811. * @returns the current particle system
  67812. */
  67813. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  67814. /**
  67815. * Remove a specific drag gradient
  67816. * @param gradient defines the gradient to remove
  67817. * @returns the current particle system
  67818. */
  67819. removeDragGradient(gradient: number): GPUParticleSystem;
  67820. /**
  67821. * Not supported by GPUParticleSystem
  67822. * @param gradient defines the gradient to use (between 0 and 1)
  67823. * @param factor defines the emit rate value to affect to the specified gradient
  67824. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67825. * @returns the current particle system
  67826. */
  67827. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67828. /**
  67829. * Not supported by GPUParticleSystem
  67830. * @param gradient defines the gradient to remove
  67831. * @returns the current particle system
  67832. */
  67833. removeEmitRateGradient(gradient: number): IParticleSystem;
  67834. /**
  67835. * Not supported by GPUParticleSystem
  67836. * @param gradient defines the gradient to use (between 0 and 1)
  67837. * @param factor defines the start size value to affect to the specified gradient
  67838. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67839. * @returns the current particle system
  67840. */
  67841. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67842. /**
  67843. * Not supported by GPUParticleSystem
  67844. * @param gradient defines the gradient to remove
  67845. * @returns the current particle system
  67846. */
  67847. removeStartSizeGradient(gradient: number): IParticleSystem;
  67848. /**
  67849. * Not supported by GPUParticleSystem
  67850. * @param gradient defines the gradient to use (between 0 and 1)
  67851. * @param min defines the color remap minimal range
  67852. * @param max defines the color remap maximal range
  67853. * @returns the current particle system
  67854. */
  67855. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67856. /**
  67857. * Not supported by GPUParticleSystem
  67858. * @param gradient defines the gradient to remove
  67859. * @returns the current particle system
  67860. */
  67861. removeColorRemapGradient(): IParticleSystem;
  67862. /**
  67863. * Not supported by GPUParticleSystem
  67864. * @param gradient defines the gradient to use (between 0 and 1)
  67865. * @param min defines the alpha remap minimal range
  67866. * @param max defines the alpha remap maximal range
  67867. * @returns the current particle system
  67868. */
  67869. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67870. /**
  67871. * Not supported by GPUParticleSystem
  67872. * @param gradient defines the gradient to remove
  67873. * @returns the current particle system
  67874. */
  67875. removeAlphaRemapGradient(): IParticleSystem;
  67876. /**
  67877. * Not supported by GPUParticleSystem
  67878. * @param gradient defines the gradient to use (between 0 and 1)
  67879. * @param color defines the color to affect to the specified gradient
  67880. * @returns the current particle system
  67881. */
  67882. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  67883. /**
  67884. * Not supported by GPUParticleSystem
  67885. * @param gradient defines the gradient to remove
  67886. * @returns the current particle system
  67887. */
  67888. removeRampGradient(): IParticleSystem;
  67889. /**
  67890. * Not supported by GPUParticleSystem
  67891. * @returns the list of ramp gradients
  67892. */
  67893. getRampGradients(): Nullable<Array<Color3Gradient>>;
  67894. /**
  67895. * Not supported by GPUParticleSystem
  67896. * Gets or sets a boolean indicating that ramp gradients must be used
  67897. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  67898. */
  67899. get useRampGradients(): boolean;
  67900. set useRampGradients(value: boolean);
  67901. /**
  67902. * Not supported by GPUParticleSystem
  67903. * @param gradient defines the gradient to use (between 0 and 1)
  67904. * @param factor defines the life time factor to affect to the specified gradient
  67905. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67906. * @returns the current particle system
  67907. */
  67908. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67909. /**
  67910. * Not supported by GPUParticleSystem
  67911. * @param gradient defines the gradient to remove
  67912. * @returns the current particle system
  67913. */
  67914. removeLifeTimeGradient(gradient: number): IParticleSystem;
  67915. /**
  67916. * Instantiates a GPU particle system.
  67917. * 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.
  67918. * @param name The name of the particle system
  67919. * @param options The options used to create the system
  67920. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  67921. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  67922. * @param customEffect a custom effect used to change the way particles are rendered by default
  67923. */
  67924. constructor(name: string, options: Partial<{
  67925. capacity: number;
  67926. randomTextureSize: number;
  67927. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  67928. protected _reset(): void;
  67929. private _createUpdateVAO;
  67930. private _createRenderVAO;
  67931. private _initialize;
  67932. /** @hidden */
  67933. _recreateUpdateEffect(): void;
  67934. private _getEffect;
  67935. /**
  67936. * Fill the defines array according to the current settings of the particle system
  67937. * @param defines Array to be updated
  67938. * @param blendMode blend mode to take into account when updating the array
  67939. */
  67940. fillDefines(defines: Array<string>, blendMode?: number): void;
  67941. /**
  67942. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  67943. * @param uniforms Uniforms array to fill
  67944. * @param attributes Attributes array to fill
  67945. * @param samplers Samplers array to fill
  67946. */
  67947. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  67948. /** @hidden */
  67949. _recreateRenderEffect(): Effect;
  67950. /**
  67951. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  67952. * @param preWarm defines if we are in the pre-warmimg phase
  67953. */
  67954. animate(preWarm?: boolean): void;
  67955. private _createFactorGradientTexture;
  67956. private _createSizeGradientTexture;
  67957. private _createAngularSpeedGradientTexture;
  67958. private _createVelocityGradientTexture;
  67959. private _createLimitVelocityGradientTexture;
  67960. private _createDragGradientTexture;
  67961. private _createColorGradientTexture;
  67962. /**
  67963. * Renders the particle system in its current state
  67964. * @param preWarm defines if the system should only update the particles but not render them
  67965. * @returns the current number of particles
  67966. */
  67967. render(preWarm?: boolean): number;
  67968. /**
  67969. * Rebuilds the particle system
  67970. */
  67971. rebuild(): void;
  67972. private _releaseBuffers;
  67973. private _releaseVAOs;
  67974. /**
  67975. * Disposes the particle system and free the associated resources
  67976. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  67977. */
  67978. dispose(disposeTexture?: boolean): void;
  67979. /**
  67980. * Clones the particle system.
  67981. * @param name The name of the cloned object
  67982. * @param newEmitter The new emitter to use
  67983. * @returns the cloned particle system
  67984. */
  67985. clone(name: string, newEmitter: any): GPUParticleSystem;
  67986. /**
  67987. * Serializes the particle system to a JSON object
  67988. * @param serializeTexture defines if the texture must be serialized as well
  67989. * @returns the JSON object
  67990. */
  67991. serialize(serializeTexture?: boolean): any;
  67992. /**
  67993. * Parses a JSON object to create a GPU particle system.
  67994. * @param parsedParticleSystem The JSON object to parse
  67995. * @param sceneOrEngine The scene or the engine to create the particle system in
  67996. * @param rootUrl The root url to use to load external dependencies like texture
  67997. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  67998. * @returns the parsed GPU particle system
  67999. */
  68000. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  68001. }
  68002. }
  68003. declare module BABYLON {
  68004. /**
  68005. * Represents a set of particle systems working together to create a specific effect
  68006. */
  68007. export class ParticleSystemSet implements IDisposable {
  68008. /**
  68009. * Gets or sets base Assets URL
  68010. */
  68011. static BaseAssetsUrl: string;
  68012. private _emitterCreationOptions;
  68013. private _emitterNode;
  68014. /**
  68015. * Gets the particle system list
  68016. */
  68017. systems: IParticleSystem[];
  68018. /**
  68019. * Gets the emitter node used with this set
  68020. */
  68021. get emitterNode(): Nullable<TransformNode>;
  68022. /**
  68023. * Creates a new emitter mesh as a sphere
  68024. * @param options defines the options used to create the sphere
  68025. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  68026. * @param scene defines the hosting scene
  68027. */
  68028. setEmitterAsSphere(options: {
  68029. diameter: number;
  68030. segments: number;
  68031. color: Color3;
  68032. }, renderingGroupId: number, scene: Scene): void;
  68033. /**
  68034. * Starts all particle systems of the set
  68035. * @param emitter defines an optional mesh to use as emitter for the particle systems
  68036. */
  68037. start(emitter?: AbstractMesh): void;
  68038. /**
  68039. * Release all associated resources
  68040. */
  68041. dispose(): void;
  68042. /**
  68043. * Serialize the set into a JSON compatible object
  68044. * @param serializeTexture defines if the texture must be serialized as well
  68045. * @returns a JSON compatible representation of the set
  68046. */
  68047. serialize(serializeTexture?: boolean): any;
  68048. /**
  68049. * Parse a new ParticleSystemSet from a serialized source
  68050. * @param data defines a JSON compatible representation of the set
  68051. * @param scene defines the hosting scene
  68052. * @param gpu defines if we want GPU particles or CPU particles
  68053. * @returns a new ParticleSystemSet
  68054. */
  68055. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  68056. }
  68057. }
  68058. declare module BABYLON {
  68059. /**
  68060. * This class is made for on one-liner static method to help creating particle system set.
  68061. */
  68062. export class ParticleHelper {
  68063. /**
  68064. * Gets or sets base Assets URL
  68065. */
  68066. static BaseAssetsUrl: string;
  68067. /** Define the Url to load snippets */
  68068. static SnippetUrl: string;
  68069. /**
  68070. * Create a default particle system that you can tweak
  68071. * @param emitter defines the emitter to use
  68072. * @param capacity defines the system capacity (default is 500 particles)
  68073. * @param scene defines the hosting scene
  68074. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  68075. * @returns the new Particle system
  68076. */
  68077. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  68078. /**
  68079. * This is the main static method (one-liner) of this helper to create different particle systems
  68080. * @param type This string represents the type to the particle system to create
  68081. * @param scene The scene where the particle system should live
  68082. * @param gpu If the system will use gpu
  68083. * @returns the ParticleSystemSet created
  68084. */
  68085. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  68086. /**
  68087. * Static function used to export a particle system to a ParticleSystemSet variable.
  68088. * Please note that the emitter shape is not exported
  68089. * @param systems defines the particle systems to export
  68090. * @returns the created particle system set
  68091. */
  68092. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  68093. /**
  68094. * Creates a particle system from a snippet saved in a remote file
  68095. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  68096. * @param url defines the url to load from
  68097. * @param scene defines the hosting scene
  68098. * @param gpu If the system will use gpu
  68099. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68100. * @returns a promise that will resolve to the new particle system
  68101. */
  68102. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  68103. /**
  68104. * Creates a particle system from a snippet saved by the particle system editor
  68105. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  68106. * @param scene defines the hosting scene
  68107. * @param gpu If the system will use gpu
  68108. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68109. * @returns a promise that will resolve to the new particle system
  68110. */
  68111. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  68112. }
  68113. }
  68114. declare module BABYLON {
  68115. interface Engine {
  68116. /**
  68117. * Create an effect to use with particle systems.
  68118. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  68119. * the particle system for which you want to create a custom effect in the last parameter
  68120. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  68121. * @param uniformsNames defines a list of attribute names
  68122. * @param samplers defines an array of string used to represent textures
  68123. * @param defines defines the string containing the defines to use to compile the shaders
  68124. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  68125. * @param onCompiled defines a function to call when the effect creation is successful
  68126. * @param onError defines a function to call when the effect creation has failed
  68127. * @param particleSystem the particle system you want to create the effect for
  68128. * @returns the new Effect
  68129. */
  68130. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  68131. }
  68132. interface Mesh {
  68133. /**
  68134. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  68135. * @returns an array of IParticleSystem
  68136. */
  68137. getEmittedParticleSystems(): IParticleSystem[];
  68138. /**
  68139. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  68140. * @returns an array of IParticleSystem
  68141. */
  68142. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  68143. }
  68144. }
  68145. declare module BABYLON {
  68146. /** Defines the 4 color options */
  68147. export enum PointColor {
  68148. /** color value */
  68149. Color = 2,
  68150. /** uv value */
  68151. UV = 1,
  68152. /** random value */
  68153. Random = 0,
  68154. /** stated value */
  68155. Stated = 3
  68156. }
  68157. /**
  68158. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  68159. * 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.
  68160. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  68161. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  68162. *
  68163. * Full documentation here : TO BE ENTERED
  68164. */
  68165. export class PointsCloudSystem implements IDisposable {
  68166. /**
  68167. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  68168. * Example : var p = SPS.particles[i];
  68169. */
  68170. particles: CloudPoint[];
  68171. /**
  68172. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  68173. */
  68174. nbParticles: number;
  68175. /**
  68176. * This a counter for your own usage. It's not set by any SPS functions.
  68177. */
  68178. counter: number;
  68179. /**
  68180. * The PCS name. This name is also given to the underlying mesh.
  68181. */
  68182. name: string;
  68183. /**
  68184. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  68185. */
  68186. mesh: Mesh;
  68187. /**
  68188. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  68189. * Please read :
  68190. */
  68191. vars: any;
  68192. /**
  68193. * @hidden
  68194. */
  68195. _size: number;
  68196. private _scene;
  68197. private _promises;
  68198. private _positions;
  68199. private _indices;
  68200. private _normals;
  68201. private _colors;
  68202. private _uvs;
  68203. private _indices32;
  68204. private _positions32;
  68205. private _colors32;
  68206. private _uvs32;
  68207. private _updatable;
  68208. private _isVisibilityBoxLocked;
  68209. private _alwaysVisible;
  68210. private _groups;
  68211. private _groupCounter;
  68212. private _computeParticleColor;
  68213. private _computeParticleTexture;
  68214. private _computeParticleRotation;
  68215. private _computeBoundingBox;
  68216. private _isReady;
  68217. /**
  68218. * Creates a PCS (Points Cloud System) object
  68219. * @param name (String) is the PCS name, this will be the underlying mesh name
  68220. * @param pointSize (number) is the size for each point
  68221. * @param scene (Scene) is the scene in which the PCS is added
  68222. * @param options defines the options of the PCS e.g.
  68223. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  68224. */
  68225. constructor(name: string, pointSize: number, scene: Scene, options?: {
  68226. updatable?: boolean;
  68227. });
  68228. /**
  68229. * Builds the PCS underlying mesh. Returns a standard Mesh.
  68230. * If no points were added to the PCS, the returned mesh is just a single point.
  68231. * @returns a promise for the created mesh
  68232. */
  68233. buildMeshAsync(): Promise<Mesh>;
  68234. /**
  68235. * @hidden
  68236. */
  68237. private _buildMesh;
  68238. private _addParticle;
  68239. private _randomUnitVector;
  68240. private _getColorIndicesForCoord;
  68241. private _setPointsColorOrUV;
  68242. private _colorFromTexture;
  68243. private _calculateDensity;
  68244. /**
  68245. * Adds points to the PCS in random positions within a unit sphere
  68246. * @param nb (positive integer) the number of particles to be created from this model
  68247. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  68248. * @returns the number of groups in the system
  68249. */
  68250. addPoints(nb: number, pointFunction?: any): number;
  68251. /**
  68252. * Adds points to the PCS from the surface of the model shape
  68253. * @param mesh is any Mesh object that will be used as a surface model for the points
  68254. * @param nb (positive integer) the number of particles to be created from this model
  68255. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68256. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68257. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68258. * @returns the number of groups in the system
  68259. */
  68260. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68261. /**
  68262. * Adds points to the PCS inside the model shape
  68263. * @param mesh is any Mesh object that will be used as a surface model for the points
  68264. * @param nb (positive integer) the number of particles to be created from this model
  68265. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68266. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68267. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68268. * @returns the number of groups in the system
  68269. */
  68270. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68271. /**
  68272. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  68273. * This method calls `updateParticle()` for each particle of the SPS.
  68274. * For an animated SPS, it is usually called within the render loop.
  68275. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  68276. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  68277. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  68278. * @returns the PCS.
  68279. */
  68280. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  68281. /**
  68282. * Disposes the PCS.
  68283. */
  68284. dispose(): void;
  68285. /**
  68286. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  68287. * doc :
  68288. * @returns the PCS.
  68289. */
  68290. refreshVisibleSize(): PointsCloudSystem;
  68291. /**
  68292. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  68293. * @param size the size (float) of the visibility box
  68294. * note : this doesn't lock the PCS mesh bounding box.
  68295. * doc :
  68296. */
  68297. setVisibilityBox(size: number): void;
  68298. /**
  68299. * Gets whether the PCS is always visible or not
  68300. * doc :
  68301. */
  68302. get isAlwaysVisible(): boolean;
  68303. /**
  68304. * Sets the PCS as always visible or not
  68305. * doc :
  68306. */
  68307. set isAlwaysVisible(val: boolean);
  68308. /**
  68309. * Tells to `setParticles()` to compute the particle rotations or not
  68310. * Default value : false. The PCS is faster when it's set to false
  68311. * Note : particle rotations are only applied to parent particles
  68312. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  68313. */
  68314. set computeParticleRotation(val: boolean);
  68315. /**
  68316. * Tells to `setParticles()` to compute the particle colors or not.
  68317. * Default value : true. The PCS is faster when it's set to false.
  68318. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68319. */
  68320. set computeParticleColor(val: boolean);
  68321. set computeParticleTexture(val: boolean);
  68322. /**
  68323. * Gets if `setParticles()` computes the particle colors or not.
  68324. * Default value : false. The PCS is faster when it's set to false.
  68325. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68326. */
  68327. get computeParticleColor(): boolean;
  68328. /**
  68329. * Gets if `setParticles()` computes the particle textures or not.
  68330. * Default value : false. The PCS is faster when it's set to false.
  68331. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  68332. */
  68333. get computeParticleTexture(): boolean;
  68334. /**
  68335. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  68336. */
  68337. set computeBoundingBox(val: boolean);
  68338. /**
  68339. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  68340. */
  68341. get computeBoundingBox(): boolean;
  68342. /**
  68343. * This function does nothing. It may be overwritten to set all the particle first values.
  68344. * The PCS doesn't call this function, you may have to call it by your own.
  68345. * doc :
  68346. */
  68347. initParticles(): void;
  68348. /**
  68349. * This function does nothing. It may be overwritten to recycle a particle
  68350. * The PCS doesn't call this function, you can to call it
  68351. * doc :
  68352. * @param particle The particle to recycle
  68353. * @returns the recycled particle
  68354. */
  68355. recycleParticle(particle: CloudPoint): CloudPoint;
  68356. /**
  68357. * Updates a particle : this function should be overwritten by the user.
  68358. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  68359. * doc :
  68360. * @example : just set a particle position or velocity and recycle conditions
  68361. * @param particle The particle to update
  68362. * @returns the updated particle
  68363. */
  68364. updateParticle(particle: CloudPoint): CloudPoint;
  68365. /**
  68366. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  68367. * This does nothing and may be overwritten by the user.
  68368. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68369. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68370. * @param update the boolean update value actually passed to setParticles()
  68371. */
  68372. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68373. /**
  68374. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  68375. * This will be passed three parameters.
  68376. * This does nothing and may be overwritten by the user.
  68377. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68378. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68379. * @param update the boolean update value actually passed to setParticles()
  68380. */
  68381. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68382. }
  68383. }
  68384. declare module BABYLON {
  68385. /**
  68386. * Represents one particle of a points cloud system.
  68387. */
  68388. export class CloudPoint {
  68389. /**
  68390. * particle global index
  68391. */
  68392. idx: number;
  68393. /**
  68394. * The color of the particle
  68395. */
  68396. color: Nullable<Color4>;
  68397. /**
  68398. * The world space position of the particle.
  68399. */
  68400. position: Vector3;
  68401. /**
  68402. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  68403. */
  68404. rotation: Vector3;
  68405. /**
  68406. * The world space rotation quaternion of the particle.
  68407. */
  68408. rotationQuaternion: Nullable<Quaternion>;
  68409. /**
  68410. * The uv of the particle.
  68411. */
  68412. uv: Nullable<Vector2>;
  68413. /**
  68414. * The current speed of the particle.
  68415. */
  68416. velocity: Vector3;
  68417. /**
  68418. * The pivot point in the particle local space.
  68419. */
  68420. pivot: Vector3;
  68421. /**
  68422. * Must the particle be translated from its pivot point in its local space ?
  68423. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  68424. * Default : false
  68425. */
  68426. translateFromPivot: boolean;
  68427. /**
  68428. * Index of this particle in the global "positions" array (Internal use)
  68429. * @hidden
  68430. */
  68431. _pos: number;
  68432. /**
  68433. * @hidden Index of this particle in the global "indices" array (Internal use)
  68434. */
  68435. _ind: number;
  68436. /**
  68437. * Group this particle belongs to
  68438. */
  68439. _group: PointsGroup;
  68440. /**
  68441. * Group id of this particle
  68442. */
  68443. groupId: number;
  68444. /**
  68445. * Index of the particle in its group id (Internal use)
  68446. */
  68447. idxInGroup: number;
  68448. /**
  68449. * @hidden Particle BoundingInfo object (Internal use)
  68450. */
  68451. _boundingInfo: BoundingInfo;
  68452. /**
  68453. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  68454. */
  68455. _pcs: PointsCloudSystem;
  68456. /**
  68457. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  68458. */
  68459. _stillInvisible: boolean;
  68460. /**
  68461. * @hidden Last computed particle rotation matrix
  68462. */
  68463. _rotationMatrix: number[];
  68464. /**
  68465. * Parent particle Id, if any.
  68466. * Default null.
  68467. */
  68468. parentId: Nullable<number>;
  68469. /**
  68470. * @hidden Internal global position in the PCS.
  68471. */
  68472. _globalPosition: Vector3;
  68473. /**
  68474. * Creates a Point Cloud object.
  68475. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  68476. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  68477. * @param group (PointsGroup) is the group the particle belongs to
  68478. * @param groupId (integer) is the group identifier in the PCS.
  68479. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  68480. * @param pcs defines the PCS it is associated to
  68481. */
  68482. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  68483. /**
  68484. * get point size
  68485. */
  68486. get size(): Vector3;
  68487. /**
  68488. * Set point size
  68489. */
  68490. set size(scale: Vector3);
  68491. /**
  68492. * Legacy support, changed quaternion to rotationQuaternion
  68493. */
  68494. get quaternion(): Nullable<Quaternion>;
  68495. /**
  68496. * Legacy support, changed quaternion to rotationQuaternion
  68497. */
  68498. set quaternion(q: Nullable<Quaternion>);
  68499. /**
  68500. * Returns a boolean. True if the particle intersects a mesh, else false
  68501. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  68502. * @param target is the object (point or mesh) what the intersection is computed against
  68503. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  68504. * @returns true if it intersects
  68505. */
  68506. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  68507. /**
  68508. * get the rotation matrix of the particle
  68509. * @hidden
  68510. */
  68511. getRotationMatrix(m: Matrix): void;
  68512. }
  68513. /**
  68514. * Represents a group of points in a points cloud system
  68515. * * PCS internal tool, don't use it manually.
  68516. */
  68517. export class PointsGroup {
  68518. /**
  68519. * The group id
  68520. * @hidden
  68521. */
  68522. groupID: number;
  68523. /**
  68524. * image data for group (internal use)
  68525. * @hidden
  68526. */
  68527. _groupImageData: Nullable<ArrayBufferView>;
  68528. /**
  68529. * Image Width (internal use)
  68530. * @hidden
  68531. */
  68532. _groupImgWidth: number;
  68533. /**
  68534. * Image Height (internal use)
  68535. * @hidden
  68536. */
  68537. _groupImgHeight: number;
  68538. /**
  68539. * Custom position function (internal use)
  68540. * @hidden
  68541. */
  68542. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  68543. /**
  68544. * density per facet for surface points
  68545. * @hidden
  68546. */
  68547. _groupDensity: number[];
  68548. /**
  68549. * Only when points are colored by texture carries pointer to texture list array
  68550. * @hidden
  68551. */
  68552. _textureNb: number;
  68553. /**
  68554. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  68555. * PCS internal tool, don't use it manually.
  68556. * @hidden
  68557. */
  68558. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  68559. }
  68560. }
  68561. declare module BABYLON {
  68562. interface Scene {
  68563. /** @hidden (Backing field) */
  68564. _physicsEngine: Nullable<IPhysicsEngine>;
  68565. /** @hidden */
  68566. _physicsTimeAccumulator: number;
  68567. /**
  68568. * Gets the current physics engine
  68569. * @returns a IPhysicsEngine or null if none attached
  68570. */
  68571. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  68572. /**
  68573. * Enables physics to the current scene
  68574. * @param gravity defines the scene's gravity for the physics engine
  68575. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  68576. * @return a boolean indicating if the physics engine was initialized
  68577. */
  68578. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  68579. /**
  68580. * Disables and disposes the physics engine associated with the scene
  68581. */
  68582. disablePhysicsEngine(): void;
  68583. /**
  68584. * Gets a boolean indicating if there is an active physics engine
  68585. * @returns a boolean indicating if there is an active physics engine
  68586. */
  68587. isPhysicsEnabled(): boolean;
  68588. /**
  68589. * Deletes a physics compound impostor
  68590. * @param compound defines the compound to delete
  68591. */
  68592. deleteCompoundImpostor(compound: any): void;
  68593. /**
  68594. * An event triggered when physic simulation is about to be run
  68595. */
  68596. onBeforePhysicsObservable: Observable<Scene>;
  68597. /**
  68598. * An event triggered when physic simulation has been done
  68599. */
  68600. onAfterPhysicsObservable: Observable<Scene>;
  68601. }
  68602. interface AbstractMesh {
  68603. /** @hidden */
  68604. _physicsImpostor: Nullable<PhysicsImpostor>;
  68605. /**
  68606. * Gets or sets impostor used for physic simulation
  68607. * @see https://doc.babylonjs.com/features/physics_engine
  68608. */
  68609. physicsImpostor: Nullable<PhysicsImpostor>;
  68610. /**
  68611. * Gets the current physics impostor
  68612. * @see https://doc.babylonjs.com/features/physics_engine
  68613. * @returns a physics impostor or null
  68614. */
  68615. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  68616. /** Apply a physic impulse to the mesh
  68617. * @param force defines the force to apply
  68618. * @param contactPoint defines where to apply the force
  68619. * @returns the current mesh
  68620. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  68621. */
  68622. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  68623. /**
  68624. * Creates a physic joint between two meshes
  68625. * @param otherMesh defines the other mesh to use
  68626. * @param pivot1 defines the pivot to use on this mesh
  68627. * @param pivot2 defines the pivot to use on the other mesh
  68628. * @param options defines additional options (can be plugin dependent)
  68629. * @returns the current mesh
  68630. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  68631. */
  68632. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  68633. /** @hidden */
  68634. _disposePhysicsObserver: Nullable<Observer<Node>>;
  68635. }
  68636. /**
  68637. * Defines the physics engine scene component responsible to manage a physics engine
  68638. */
  68639. export class PhysicsEngineSceneComponent implements ISceneComponent {
  68640. /**
  68641. * The component name helpful to identify the component in the list of scene components.
  68642. */
  68643. readonly name: string;
  68644. /**
  68645. * The scene the component belongs to.
  68646. */
  68647. scene: Scene;
  68648. /**
  68649. * Creates a new instance of the component for the given scene
  68650. * @param scene Defines the scene to register the component in
  68651. */
  68652. constructor(scene: Scene);
  68653. /**
  68654. * Registers the component in a given scene
  68655. */
  68656. register(): void;
  68657. /**
  68658. * Rebuilds the elements related to this component in case of
  68659. * context lost for instance.
  68660. */
  68661. rebuild(): void;
  68662. /**
  68663. * Disposes the component and the associated ressources
  68664. */
  68665. dispose(): void;
  68666. }
  68667. }
  68668. declare module BABYLON {
  68669. /**
  68670. * A helper for physics simulations
  68671. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68672. */
  68673. export class PhysicsHelper {
  68674. private _scene;
  68675. private _physicsEngine;
  68676. /**
  68677. * Initializes the Physics helper
  68678. * @param scene Babylon.js scene
  68679. */
  68680. constructor(scene: Scene);
  68681. /**
  68682. * Applies a radial explosion impulse
  68683. * @param origin the origin of the explosion
  68684. * @param radiusOrEventOptions the radius or the options of radial explosion
  68685. * @param strength the explosion strength
  68686. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68687. * @returns A physics radial explosion event, or null
  68688. */
  68689. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68690. /**
  68691. * Applies a radial explosion force
  68692. * @param origin the origin of the explosion
  68693. * @param radiusOrEventOptions the radius or the options of radial explosion
  68694. * @param strength the explosion strength
  68695. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68696. * @returns A physics radial explosion event, or null
  68697. */
  68698. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68699. /**
  68700. * Creates a gravitational field
  68701. * @param origin the origin of the explosion
  68702. * @param radiusOrEventOptions the radius or the options of radial explosion
  68703. * @param strength the explosion strength
  68704. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68705. * @returns A physics gravitational field event, or null
  68706. */
  68707. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  68708. /**
  68709. * Creates a physics updraft event
  68710. * @param origin the origin of the updraft
  68711. * @param radiusOrEventOptions the radius or the options of the updraft
  68712. * @param strength the strength of the updraft
  68713. * @param height the height of the updraft
  68714. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  68715. * @returns A physics updraft event, or null
  68716. */
  68717. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  68718. /**
  68719. * Creates a physics vortex event
  68720. * @param origin the of the vortex
  68721. * @param radiusOrEventOptions the radius or the options of the vortex
  68722. * @param strength the strength of the vortex
  68723. * @param height the height of the vortex
  68724. * @returns a Physics vortex event, or null
  68725. * A physics vortex event or null
  68726. */
  68727. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  68728. }
  68729. /**
  68730. * Represents a physics radial explosion event
  68731. */
  68732. class PhysicsRadialExplosionEvent {
  68733. private _scene;
  68734. private _options;
  68735. private _sphere;
  68736. private _dataFetched;
  68737. /**
  68738. * Initializes a radial explosioin event
  68739. * @param _scene BabylonJS scene
  68740. * @param _options The options for the vortex event
  68741. */
  68742. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  68743. /**
  68744. * Returns the data related to the radial explosion event (sphere).
  68745. * @returns The radial explosion event data
  68746. */
  68747. getData(): PhysicsRadialExplosionEventData;
  68748. /**
  68749. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  68750. * @param impostor A physics imposter
  68751. * @param origin the origin of the explosion
  68752. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  68753. */
  68754. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  68755. /**
  68756. * Triggers affecterd impostors callbacks
  68757. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  68758. */
  68759. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  68760. /**
  68761. * Disposes the sphere.
  68762. * @param force Specifies if the sphere should be disposed by force
  68763. */
  68764. dispose(force?: boolean): void;
  68765. /*** Helpers ***/
  68766. private _prepareSphere;
  68767. private _intersectsWithSphere;
  68768. }
  68769. /**
  68770. * Represents a gravitational field event
  68771. */
  68772. class PhysicsGravitationalFieldEvent {
  68773. private _physicsHelper;
  68774. private _scene;
  68775. private _origin;
  68776. private _options;
  68777. private _tickCallback;
  68778. private _sphere;
  68779. private _dataFetched;
  68780. /**
  68781. * Initializes the physics gravitational field event
  68782. * @param _physicsHelper A physics helper
  68783. * @param _scene BabylonJS scene
  68784. * @param _origin The origin position of the gravitational field event
  68785. * @param _options The options for the vortex event
  68786. */
  68787. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  68788. /**
  68789. * Returns the data related to the gravitational field event (sphere).
  68790. * @returns A gravitational field event
  68791. */
  68792. getData(): PhysicsGravitationalFieldEventData;
  68793. /**
  68794. * Enables the gravitational field.
  68795. */
  68796. enable(): void;
  68797. /**
  68798. * Disables the gravitational field.
  68799. */
  68800. disable(): void;
  68801. /**
  68802. * Disposes the sphere.
  68803. * @param force The force to dispose from the gravitational field event
  68804. */
  68805. dispose(force?: boolean): void;
  68806. private _tick;
  68807. }
  68808. /**
  68809. * Represents a physics updraft event
  68810. */
  68811. class PhysicsUpdraftEvent {
  68812. private _scene;
  68813. private _origin;
  68814. private _options;
  68815. private _physicsEngine;
  68816. private _originTop;
  68817. private _originDirection;
  68818. private _tickCallback;
  68819. private _cylinder;
  68820. private _cylinderPosition;
  68821. private _dataFetched;
  68822. /**
  68823. * Initializes the physics updraft event
  68824. * @param _scene BabylonJS scene
  68825. * @param _origin The origin position of the updraft
  68826. * @param _options The options for the updraft event
  68827. */
  68828. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  68829. /**
  68830. * Returns the data related to the updraft event (cylinder).
  68831. * @returns A physics updraft event
  68832. */
  68833. getData(): PhysicsUpdraftEventData;
  68834. /**
  68835. * Enables the updraft.
  68836. */
  68837. enable(): void;
  68838. /**
  68839. * Disables the updraft.
  68840. */
  68841. disable(): void;
  68842. /**
  68843. * Disposes the cylinder.
  68844. * @param force Specifies if the updraft should be disposed by force
  68845. */
  68846. dispose(force?: boolean): void;
  68847. private getImpostorHitData;
  68848. private _tick;
  68849. /*** Helpers ***/
  68850. private _prepareCylinder;
  68851. private _intersectsWithCylinder;
  68852. }
  68853. /**
  68854. * Represents a physics vortex event
  68855. */
  68856. class PhysicsVortexEvent {
  68857. private _scene;
  68858. private _origin;
  68859. private _options;
  68860. private _physicsEngine;
  68861. private _originTop;
  68862. private _tickCallback;
  68863. private _cylinder;
  68864. private _cylinderPosition;
  68865. private _dataFetched;
  68866. /**
  68867. * Initializes the physics vortex event
  68868. * @param _scene The BabylonJS scene
  68869. * @param _origin The origin position of the vortex
  68870. * @param _options The options for the vortex event
  68871. */
  68872. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  68873. /**
  68874. * Returns the data related to the vortex event (cylinder).
  68875. * @returns The physics vortex event data
  68876. */
  68877. getData(): PhysicsVortexEventData;
  68878. /**
  68879. * Enables the vortex.
  68880. */
  68881. enable(): void;
  68882. /**
  68883. * Disables the cortex.
  68884. */
  68885. disable(): void;
  68886. /**
  68887. * Disposes the sphere.
  68888. * @param force
  68889. */
  68890. dispose(force?: boolean): void;
  68891. private getImpostorHitData;
  68892. private _tick;
  68893. /*** Helpers ***/
  68894. private _prepareCylinder;
  68895. private _intersectsWithCylinder;
  68896. }
  68897. /**
  68898. * Options fot the radial explosion event
  68899. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68900. */
  68901. export class PhysicsRadialExplosionEventOptions {
  68902. /**
  68903. * The radius of the sphere for the radial explosion.
  68904. */
  68905. radius: number;
  68906. /**
  68907. * The strenth of the explosion.
  68908. */
  68909. strength: number;
  68910. /**
  68911. * The strenght of the force in correspondence to the distance of the affected object
  68912. */
  68913. falloff: PhysicsRadialImpulseFalloff;
  68914. /**
  68915. * Sphere options for the radial explosion.
  68916. */
  68917. sphere: {
  68918. segments: number;
  68919. diameter: number;
  68920. };
  68921. /**
  68922. * Sphere options for the radial explosion.
  68923. */
  68924. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  68925. }
  68926. /**
  68927. * Options fot the updraft event
  68928. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68929. */
  68930. export class PhysicsUpdraftEventOptions {
  68931. /**
  68932. * The radius of the cylinder for the vortex
  68933. */
  68934. radius: number;
  68935. /**
  68936. * The strenth of the updraft.
  68937. */
  68938. strength: number;
  68939. /**
  68940. * The height of the cylinder for the updraft.
  68941. */
  68942. height: number;
  68943. /**
  68944. * The mode for the the updraft.
  68945. */
  68946. updraftMode: PhysicsUpdraftMode;
  68947. }
  68948. /**
  68949. * Options fot the vortex event
  68950. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68951. */
  68952. export class PhysicsVortexEventOptions {
  68953. /**
  68954. * The radius of the cylinder for the vortex
  68955. */
  68956. radius: number;
  68957. /**
  68958. * The strenth of the vortex.
  68959. */
  68960. strength: number;
  68961. /**
  68962. * The height of the cylinder for the vortex.
  68963. */
  68964. height: number;
  68965. /**
  68966. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  68967. */
  68968. centripetalForceThreshold: number;
  68969. /**
  68970. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  68971. */
  68972. centripetalForceMultiplier: number;
  68973. /**
  68974. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  68975. */
  68976. centrifugalForceMultiplier: number;
  68977. /**
  68978. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  68979. */
  68980. updraftForceMultiplier: number;
  68981. }
  68982. /**
  68983. * The strenght of the force in correspondence to the distance of the affected object
  68984. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68985. */
  68986. export enum PhysicsRadialImpulseFalloff {
  68987. /** Defines that impulse is constant in strength across it's whole radius */
  68988. Constant = 0,
  68989. /** Defines that impulse gets weaker if it's further from the origin */
  68990. Linear = 1
  68991. }
  68992. /**
  68993. * The strength of the force in correspondence to the distance of the affected object
  68994. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68995. */
  68996. export enum PhysicsUpdraftMode {
  68997. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  68998. Center = 0,
  68999. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  69000. Perpendicular = 1
  69001. }
  69002. /**
  69003. * Interface for a physics hit data
  69004. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69005. */
  69006. export interface PhysicsHitData {
  69007. /**
  69008. * The force applied at the contact point
  69009. */
  69010. force: Vector3;
  69011. /**
  69012. * The contact point
  69013. */
  69014. contactPoint: Vector3;
  69015. /**
  69016. * The distance from the origin to the contact point
  69017. */
  69018. distanceFromOrigin: number;
  69019. }
  69020. /**
  69021. * Interface for radial explosion event data
  69022. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69023. */
  69024. export interface PhysicsRadialExplosionEventData {
  69025. /**
  69026. * A sphere used for the radial explosion event
  69027. */
  69028. sphere: Mesh;
  69029. }
  69030. /**
  69031. * Interface for gravitational field event data
  69032. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69033. */
  69034. export interface PhysicsGravitationalFieldEventData {
  69035. /**
  69036. * A sphere mesh used for the gravitational field event
  69037. */
  69038. sphere: Mesh;
  69039. }
  69040. /**
  69041. * Interface for updraft event data
  69042. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69043. */
  69044. export interface PhysicsUpdraftEventData {
  69045. /**
  69046. * A cylinder used for the updraft event
  69047. */
  69048. cylinder: Mesh;
  69049. }
  69050. /**
  69051. * Interface for vortex event data
  69052. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69053. */
  69054. export interface PhysicsVortexEventData {
  69055. /**
  69056. * A cylinder used for the vortex event
  69057. */
  69058. cylinder: Mesh;
  69059. }
  69060. /**
  69061. * Interface for an affected physics impostor
  69062. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69063. */
  69064. export interface PhysicsAffectedImpostorWithData {
  69065. /**
  69066. * The impostor affected by the effect
  69067. */
  69068. impostor: PhysicsImpostor;
  69069. /**
  69070. * The data about the hit/horce from the explosion
  69071. */
  69072. hitData: PhysicsHitData;
  69073. }
  69074. }
  69075. declare module BABYLON {
  69076. /** @hidden */
  69077. export var blackAndWhitePixelShader: {
  69078. name: string;
  69079. shader: string;
  69080. };
  69081. }
  69082. declare module BABYLON {
  69083. /**
  69084. * Post process used to render in black and white
  69085. */
  69086. export class BlackAndWhitePostProcess extends PostProcess {
  69087. /**
  69088. * Linear about to convert he result to black and white (default: 1)
  69089. */
  69090. degree: number;
  69091. /**
  69092. * Gets a string identifying the name of the class
  69093. * @returns "BlackAndWhitePostProcess" string
  69094. */
  69095. getClassName(): string;
  69096. /**
  69097. * Creates a black and white post process
  69098. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  69099. * @param name The name of the effect.
  69100. * @param options The required width/height ratio to downsize to before computing the render pass.
  69101. * @param camera The camera to apply the render pass to.
  69102. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69103. * @param engine The engine which the post process will be applied. (default: current engine)
  69104. * @param reusable If the post process can be reused on the same frame. (default: false)
  69105. */
  69106. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69107. /** @hidden */
  69108. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  69109. }
  69110. }
  69111. declare module BABYLON {
  69112. /**
  69113. * This represents a set of one or more post processes in Babylon.
  69114. * A post process can be used to apply a shader to a texture after it is rendered.
  69115. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69116. */
  69117. export class PostProcessRenderEffect {
  69118. private _postProcesses;
  69119. private _getPostProcesses;
  69120. private _singleInstance;
  69121. private _cameras;
  69122. private _indicesForCamera;
  69123. /**
  69124. * Name of the effect
  69125. * @hidden
  69126. */
  69127. _name: string;
  69128. /**
  69129. * Instantiates a post process render effect.
  69130. * A post process can be used to apply a shader to a texture after it is rendered.
  69131. * @param engine The engine the effect is tied to
  69132. * @param name The name of the effect
  69133. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  69134. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  69135. */
  69136. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  69137. /**
  69138. * Checks if all the post processes in the effect are supported.
  69139. */
  69140. get isSupported(): boolean;
  69141. /**
  69142. * Updates the current state of the effect
  69143. * @hidden
  69144. */
  69145. _update(): void;
  69146. /**
  69147. * Attaches the effect on cameras
  69148. * @param cameras The camera to attach to.
  69149. * @hidden
  69150. */
  69151. _attachCameras(cameras: Camera): void;
  69152. /**
  69153. * Attaches the effect on cameras
  69154. * @param cameras The camera to attach to.
  69155. * @hidden
  69156. */
  69157. _attachCameras(cameras: Camera[]): void;
  69158. /**
  69159. * Detaches the effect on cameras
  69160. * @param cameras The camera to detatch from.
  69161. * @hidden
  69162. */
  69163. _detachCameras(cameras: Camera): void;
  69164. /**
  69165. * Detatches the effect on cameras
  69166. * @param cameras The camera to detatch from.
  69167. * @hidden
  69168. */
  69169. _detachCameras(cameras: Camera[]): void;
  69170. /**
  69171. * Enables the effect on given cameras
  69172. * @param cameras The camera to enable.
  69173. * @hidden
  69174. */
  69175. _enable(cameras: Camera): void;
  69176. /**
  69177. * Enables the effect on given cameras
  69178. * @param cameras The camera to enable.
  69179. * @hidden
  69180. */
  69181. _enable(cameras: Nullable<Camera[]>): void;
  69182. /**
  69183. * Disables the effect on the given cameras
  69184. * @param cameras The camera to disable.
  69185. * @hidden
  69186. */
  69187. _disable(cameras: Camera): void;
  69188. /**
  69189. * Disables the effect on the given cameras
  69190. * @param cameras The camera to disable.
  69191. * @hidden
  69192. */
  69193. _disable(cameras: Nullable<Camera[]>): void;
  69194. /**
  69195. * Gets a list of the post processes contained in the effect.
  69196. * @param camera The camera to get the post processes on.
  69197. * @returns The list of the post processes in the effect.
  69198. */
  69199. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  69200. }
  69201. }
  69202. declare module BABYLON {
  69203. /** @hidden */
  69204. export var extractHighlightsPixelShader: {
  69205. name: string;
  69206. shader: string;
  69207. };
  69208. }
  69209. declare module BABYLON {
  69210. /**
  69211. * 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.
  69212. */
  69213. export class ExtractHighlightsPostProcess extends PostProcess {
  69214. /**
  69215. * The luminance threshold, pixels below this value will be set to black.
  69216. */
  69217. threshold: number;
  69218. /** @hidden */
  69219. _exposure: number;
  69220. /**
  69221. * Post process which has the input texture to be used when performing highlight extraction
  69222. * @hidden
  69223. */
  69224. _inputPostProcess: Nullable<PostProcess>;
  69225. /**
  69226. * Gets a string identifying the name of the class
  69227. * @returns "ExtractHighlightsPostProcess" string
  69228. */
  69229. getClassName(): string;
  69230. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69231. }
  69232. }
  69233. declare module BABYLON {
  69234. /** @hidden */
  69235. export var bloomMergePixelShader: {
  69236. name: string;
  69237. shader: string;
  69238. };
  69239. }
  69240. declare module BABYLON {
  69241. /**
  69242. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  69243. */
  69244. export class BloomMergePostProcess extends PostProcess {
  69245. /** Weight of the bloom to be added to the original input. */
  69246. weight: number;
  69247. /**
  69248. * Gets a string identifying the name of the class
  69249. * @returns "BloomMergePostProcess" string
  69250. */
  69251. getClassName(): string;
  69252. /**
  69253. * Creates a new instance of @see BloomMergePostProcess
  69254. * @param name The name of the effect.
  69255. * @param originalFromInput Post process which's input will be used for the merge.
  69256. * @param blurred Blurred highlights post process which's output will be used.
  69257. * @param weight Weight of the bloom to be added to the original input.
  69258. * @param options The required width/height ratio to downsize to before computing the render pass.
  69259. * @param camera The camera to apply the render pass to.
  69260. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69261. * @param engine The engine which the post process will be applied. (default: current engine)
  69262. * @param reusable If the post process can be reused on the same frame. (default: false)
  69263. * @param textureType Type of textures used when performing the post process. (default: 0)
  69264. * @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)
  69265. */
  69266. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  69267. /** Weight of the bloom to be added to the original input. */
  69268. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69269. }
  69270. }
  69271. declare module BABYLON {
  69272. /**
  69273. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  69274. */
  69275. export class BloomEffect extends PostProcessRenderEffect {
  69276. private bloomScale;
  69277. /**
  69278. * @hidden Internal
  69279. */
  69280. _effects: Array<PostProcess>;
  69281. /**
  69282. * @hidden Internal
  69283. */
  69284. _downscale: ExtractHighlightsPostProcess;
  69285. private _blurX;
  69286. private _blurY;
  69287. private _merge;
  69288. /**
  69289. * The luminance threshold to find bright areas of the image to bloom.
  69290. */
  69291. get threshold(): number;
  69292. set threshold(value: number);
  69293. /**
  69294. * The strength of the bloom.
  69295. */
  69296. get weight(): number;
  69297. set weight(value: number);
  69298. /**
  69299. * Specifies the size of the bloom blur kernel, relative to the final output size
  69300. */
  69301. get kernel(): number;
  69302. set kernel(value: number);
  69303. /**
  69304. * Creates a new instance of @see BloomEffect
  69305. * @param scene The scene the effect belongs to.
  69306. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  69307. * @param bloomKernel The size of the kernel to be used when applying the blur.
  69308. * @param bloomWeight The the strength of bloom.
  69309. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69310. * @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)
  69311. */
  69312. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  69313. /**
  69314. * Disposes each of the internal effects for a given camera.
  69315. * @param camera The camera to dispose the effect on.
  69316. */
  69317. disposeEffects(camera: Camera): void;
  69318. /**
  69319. * @hidden Internal
  69320. */
  69321. _updateEffects(): void;
  69322. /**
  69323. * Internal
  69324. * @returns if all the contained post processes are ready.
  69325. * @hidden
  69326. */
  69327. _isReady(): boolean;
  69328. }
  69329. }
  69330. declare module BABYLON {
  69331. /** @hidden */
  69332. export var chromaticAberrationPixelShader: {
  69333. name: string;
  69334. shader: string;
  69335. };
  69336. }
  69337. declare module BABYLON {
  69338. /**
  69339. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  69340. */
  69341. export class ChromaticAberrationPostProcess extends PostProcess {
  69342. /**
  69343. * The amount of seperation of rgb channels (default: 30)
  69344. */
  69345. aberrationAmount: number;
  69346. /**
  69347. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  69348. */
  69349. radialIntensity: number;
  69350. /**
  69351. * 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))
  69352. */
  69353. direction: Vector2;
  69354. /**
  69355. * 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))
  69356. */
  69357. centerPosition: Vector2;
  69358. /** The width of the screen to apply the effect on */
  69359. screenWidth: number;
  69360. /** The height of the screen to apply the effect on */
  69361. screenHeight: number;
  69362. /**
  69363. * Gets a string identifying the name of the class
  69364. * @returns "ChromaticAberrationPostProcess" string
  69365. */
  69366. getClassName(): string;
  69367. /**
  69368. * Creates a new instance ChromaticAberrationPostProcess
  69369. * @param name The name of the effect.
  69370. * @param screenWidth The width of the screen to apply the effect on.
  69371. * @param screenHeight The height of the screen to apply the effect on.
  69372. * @param options The required width/height ratio to downsize to before computing the render pass.
  69373. * @param camera The camera to apply the render pass to.
  69374. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69375. * @param engine The engine which the post process will be applied. (default: current engine)
  69376. * @param reusable If the post process can be reused on the same frame. (default: false)
  69377. * @param textureType Type of textures used when performing the post process. (default: 0)
  69378. * @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)
  69379. */
  69380. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69381. /** @hidden */
  69382. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  69383. }
  69384. }
  69385. declare module BABYLON {
  69386. /** @hidden */
  69387. export var circleOfConfusionPixelShader: {
  69388. name: string;
  69389. shader: string;
  69390. };
  69391. }
  69392. declare module BABYLON {
  69393. /**
  69394. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  69395. */
  69396. export class CircleOfConfusionPostProcess extends PostProcess {
  69397. /**
  69398. * 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.
  69399. */
  69400. lensSize: number;
  69401. /**
  69402. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69403. */
  69404. fStop: number;
  69405. /**
  69406. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69407. */
  69408. focusDistance: number;
  69409. /**
  69410. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  69411. */
  69412. focalLength: number;
  69413. /**
  69414. * Gets a string identifying the name of the class
  69415. * @returns "CircleOfConfusionPostProcess" string
  69416. */
  69417. getClassName(): string;
  69418. private _depthTexture;
  69419. /**
  69420. * Creates a new instance CircleOfConfusionPostProcess
  69421. * @param name The name of the effect.
  69422. * @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.
  69423. * @param options The required width/height ratio to downsize to before computing the render pass.
  69424. * @param camera The camera to apply the render pass to.
  69425. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69426. * @param engine The engine which the post process will be applied. (default: current engine)
  69427. * @param reusable If the post process can be reused on the same frame. (default: false)
  69428. * @param textureType Type of textures used when performing the post process. (default: 0)
  69429. * @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)
  69430. */
  69431. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69432. /**
  69433. * 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.
  69434. */
  69435. set depthTexture(value: RenderTargetTexture);
  69436. }
  69437. }
  69438. declare module BABYLON {
  69439. /** @hidden */
  69440. export var colorCorrectionPixelShader: {
  69441. name: string;
  69442. shader: string;
  69443. };
  69444. }
  69445. declare module BABYLON {
  69446. /**
  69447. *
  69448. * This post-process allows the modification of rendered colors by using
  69449. * a 'look-up table' (LUT). This effect is also called Color Grading.
  69450. *
  69451. * The object needs to be provided an url to a texture containing the color
  69452. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  69453. * Use an image editing software to tweak the LUT to match your needs.
  69454. *
  69455. * For an example of a color LUT, see here:
  69456. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  69457. * For explanations on color grading, see here:
  69458. * @see http://udn.epicgames.com/Three/ColorGrading.html
  69459. *
  69460. */
  69461. export class ColorCorrectionPostProcess extends PostProcess {
  69462. private _colorTableTexture;
  69463. /**
  69464. * Gets the color table url used to create the LUT texture
  69465. */
  69466. colorTableUrl: string;
  69467. /**
  69468. * Gets a string identifying the name of the class
  69469. * @returns "ColorCorrectionPostProcess" string
  69470. */
  69471. getClassName(): string;
  69472. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69473. /** @hidden */
  69474. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  69475. }
  69476. }
  69477. declare module BABYLON {
  69478. /** @hidden */
  69479. export var convolutionPixelShader: {
  69480. name: string;
  69481. shader: string;
  69482. };
  69483. }
  69484. declare module BABYLON {
  69485. /**
  69486. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  69487. * input texture to perform effects such as edge detection or sharpening
  69488. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  69489. */
  69490. export class ConvolutionPostProcess extends PostProcess {
  69491. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  69492. kernel: number[];
  69493. /**
  69494. * Gets a string identifying the name of the class
  69495. * @returns "ConvolutionPostProcess" string
  69496. */
  69497. getClassName(): string;
  69498. /**
  69499. * Creates a new instance ConvolutionPostProcess
  69500. * @param name The name of the effect.
  69501. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  69502. * @param options The required width/height ratio to downsize to before computing the render pass.
  69503. * @param camera The camera to apply the render pass to.
  69504. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69505. * @param engine The engine which the post process will be applied. (default: current engine)
  69506. * @param reusable If the post process can be reused on the same frame. (default: false)
  69507. * @param textureType Type of textures used when performing the post process. (default: 0)
  69508. */
  69509. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69510. /** @hidden */
  69511. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  69512. /**
  69513. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69514. */
  69515. static EdgeDetect0Kernel: number[];
  69516. /**
  69517. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69518. */
  69519. static EdgeDetect1Kernel: number[];
  69520. /**
  69521. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69522. */
  69523. static EdgeDetect2Kernel: number[];
  69524. /**
  69525. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69526. */
  69527. static SharpenKernel: number[];
  69528. /**
  69529. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69530. */
  69531. static EmbossKernel: number[];
  69532. /**
  69533. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69534. */
  69535. static GaussianKernel: number[];
  69536. }
  69537. }
  69538. declare module BABYLON {
  69539. /**
  69540. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  69541. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  69542. * based on samples that have a large difference in distance than the center pixel.
  69543. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  69544. */
  69545. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  69546. /**
  69547. * The direction the blur should be applied
  69548. */
  69549. direction: Vector2;
  69550. /**
  69551. * Gets a string identifying the name of the class
  69552. * @returns "DepthOfFieldBlurPostProcess" string
  69553. */
  69554. getClassName(): string;
  69555. /**
  69556. * Creates a new instance CircleOfConfusionPostProcess
  69557. * @param name The name of the effect.
  69558. * @param scene The scene the effect belongs to.
  69559. * @param direction The direction the blur should be applied.
  69560. * @param kernel The size of the kernel used to blur.
  69561. * @param options The required width/height ratio to downsize to before computing the render pass.
  69562. * @param camera The camera to apply the render pass to.
  69563. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  69564. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  69565. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69566. * @param engine The engine which the post process will be applied. (default: current engine)
  69567. * @param reusable If the post process can be reused on the same frame. (default: false)
  69568. * @param textureType Type of textures used when performing the post process. (default: 0)
  69569. * @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)
  69570. */
  69571. 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);
  69572. }
  69573. }
  69574. declare module BABYLON {
  69575. /** @hidden */
  69576. export var depthOfFieldMergePixelShader: {
  69577. name: string;
  69578. shader: string;
  69579. };
  69580. }
  69581. declare module BABYLON {
  69582. /**
  69583. * Options to be set when merging outputs from the default pipeline.
  69584. */
  69585. export class DepthOfFieldMergePostProcessOptions {
  69586. /**
  69587. * The original image to merge on top of
  69588. */
  69589. originalFromInput: PostProcess;
  69590. /**
  69591. * Parameters to perform the merge of the depth of field effect
  69592. */
  69593. depthOfField?: {
  69594. circleOfConfusion: PostProcess;
  69595. blurSteps: Array<PostProcess>;
  69596. };
  69597. /**
  69598. * Parameters to perform the merge of bloom effect
  69599. */
  69600. bloom?: {
  69601. blurred: PostProcess;
  69602. weight: number;
  69603. };
  69604. }
  69605. /**
  69606. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  69607. */
  69608. export class DepthOfFieldMergePostProcess extends PostProcess {
  69609. private blurSteps;
  69610. /**
  69611. * Gets a string identifying the name of the class
  69612. * @returns "DepthOfFieldMergePostProcess" string
  69613. */
  69614. getClassName(): string;
  69615. /**
  69616. * Creates a new instance of DepthOfFieldMergePostProcess
  69617. * @param name The name of the effect.
  69618. * @param originalFromInput Post process which's input will be used for the merge.
  69619. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  69620. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  69621. * @param options The required width/height ratio to downsize to before computing the render pass.
  69622. * @param camera The camera to apply the render pass to.
  69623. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69624. * @param engine The engine which the post process will be applied. (default: current engine)
  69625. * @param reusable If the post process can be reused on the same frame. (default: false)
  69626. * @param textureType Type of textures used when performing the post process. (default: 0)
  69627. * @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)
  69628. */
  69629. 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);
  69630. /**
  69631. * Updates the effect with the current post process compile time values and recompiles the shader.
  69632. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  69633. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  69634. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  69635. * @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
  69636. * @param onCompiled Called when the shader has been compiled.
  69637. * @param onError Called if there is an error when compiling a shader.
  69638. */
  69639. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69640. }
  69641. }
  69642. declare module BABYLON {
  69643. /**
  69644. * Specifies the level of max blur that should be applied when using the depth of field effect
  69645. */
  69646. export enum DepthOfFieldEffectBlurLevel {
  69647. /**
  69648. * Subtle blur
  69649. */
  69650. Low = 0,
  69651. /**
  69652. * Medium blur
  69653. */
  69654. Medium = 1,
  69655. /**
  69656. * Large blur
  69657. */
  69658. High = 2
  69659. }
  69660. /**
  69661. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  69662. */
  69663. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  69664. private _circleOfConfusion;
  69665. /**
  69666. * @hidden Internal, blurs from high to low
  69667. */
  69668. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  69669. private _depthOfFieldBlurY;
  69670. private _dofMerge;
  69671. /**
  69672. * @hidden Internal post processes in depth of field effect
  69673. */
  69674. _effects: Array<PostProcess>;
  69675. /**
  69676. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  69677. */
  69678. set focalLength(value: number);
  69679. get focalLength(): number;
  69680. /**
  69681. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69682. */
  69683. set fStop(value: number);
  69684. get fStop(): number;
  69685. /**
  69686. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69687. */
  69688. set focusDistance(value: number);
  69689. get focusDistance(): number;
  69690. /**
  69691. * 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.
  69692. */
  69693. set lensSize(value: number);
  69694. get lensSize(): number;
  69695. /**
  69696. * Creates a new instance DepthOfFieldEffect
  69697. * @param scene The scene the effect belongs to.
  69698. * @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.
  69699. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69700. * @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)
  69701. */
  69702. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  69703. /**
  69704. * Get the current class name of the current effet
  69705. * @returns "DepthOfFieldEffect"
  69706. */
  69707. getClassName(): string;
  69708. /**
  69709. * 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.
  69710. */
  69711. set depthTexture(value: RenderTargetTexture);
  69712. /**
  69713. * Disposes each of the internal effects for a given camera.
  69714. * @param camera The camera to dispose the effect on.
  69715. */
  69716. disposeEffects(camera: Camera): void;
  69717. /**
  69718. * @hidden Internal
  69719. */
  69720. _updateEffects(): void;
  69721. /**
  69722. * Internal
  69723. * @returns if all the contained post processes are ready.
  69724. * @hidden
  69725. */
  69726. _isReady(): boolean;
  69727. }
  69728. }
  69729. declare module BABYLON {
  69730. /** @hidden */
  69731. export var displayPassPixelShader: {
  69732. name: string;
  69733. shader: string;
  69734. };
  69735. }
  69736. declare module BABYLON {
  69737. /**
  69738. * DisplayPassPostProcess which produces an output the same as it's input
  69739. */
  69740. export class DisplayPassPostProcess extends PostProcess {
  69741. /**
  69742. * Gets a string identifying the name of the class
  69743. * @returns "DisplayPassPostProcess" string
  69744. */
  69745. getClassName(): string;
  69746. /**
  69747. * Creates the DisplayPassPostProcess
  69748. * @param name The name of the effect.
  69749. * @param options The required width/height ratio to downsize to before computing the render pass.
  69750. * @param camera The camera to apply the render pass to.
  69751. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69752. * @param engine The engine which the post process will be applied. (default: current engine)
  69753. * @param reusable If the post process can be reused on the same frame. (default: false)
  69754. */
  69755. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69756. /** @hidden */
  69757. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  69758. }
  69759. }
  69760. declare module BABYLON {
  69761. /** @hidden */
  69762. export var filterPixelShader: {
  69763. name: string;
  69764. shader: string;
  69765. };
  69766. }
  69767. declare module BABYLON {
  69768. /**
  69769. * Applies a kernel filter to the image
  69770. */
  69771. export class FilterPostProcess extends PostProcess {
  69772. /** The matrix to be applied to the image */
  69773. kernelMatrix: Matrix;
  69774. /**
  69775. * Gets a string identifying the name of the class
  69776. * @returns "FilterPostProcess" string
  69777. */
  69778. getClassName(): string;
  69779. /**
  69780. *
  69781. * @param name The name of the effect.
  69782. * @param kernelMatrix The matrix to be applied to the image
  69783. * @param options The required width/height ratio to downsize to before computing the render pass.
  69784. * @param camera The camera to apply the render pass to.
  69785. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69786. * @param engine The engine which the post process will be applied. (default: current engine)
  69787. * @param reusable If the post process can be reused on the same frame. (default: false)
  69788. */
  69789. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69790. /** @hidden */
  69791. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  69792. }
  69793. }
  69794. declare module BABYLON {
  69795. /** @hidden */
  69796. export var fxaaPixelShader: {
  69797. name: string;
  69798. shader: string;
  69799. };
  69800. }
  69801. declare module BABYLON {
  69802. /** @hidden */
  69803. export var fxaaVertexShader: {
  69804. name: string;
  69805. shader: string;
  69806. };
  69807. }
  69808. declare module BABYLON {
  69809. /**
  69810. * Fxaa post process
  69811. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  69812. */
  69813. export class FxaaPostProcess extends PostProcess {
  69814. /**
  69815. * Gets a string identifying the name of the class
  69816. * @returns "FxaaPostProcess" string
  69817. */
  69818. getClassName(): string;
  69819. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69820. private _getDefines;
  69821. /** @hidden */
  69822. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  69823. }
  69824. }
  69825. declare module BABYLON {
  69826. /** @hidden */
  69827. export var grainPixelShader: {
  69828. name: string;
  69829. shader: string;
  69830. };
  69831. }
  69832. declare module BABYLON {
  69833. /**
  69834. * The GrainPostProcess adds noise to the image at mid luminance levels
  69835. */
  69836. export class GrainPostProcess extends PostProcess {
  69837. /**
  69838. * The intensity of the grain added (default: 30)
  69839. */
  69840. intensity: number;
  69841. /**
  69842. * If the grain should be randomized on every frame
  69843. */
  69844. animated: boolean;
  69845. /**
  69846. * Gets a string identifying the name of the class
  69847. * @returns "GrainPostProcess" string
  69848. */
  69849. getClassName(): string;
  69850. /**
  69851. * Creates a new instance of @see GrainPostProcess
  69852. * @param name The name of the effect.
  69853. * @param options The required width/height ratio to downsize to before computing the render pass.
  69854. * @param camera The camera to apply the render pass to.
  69855. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69856. * @param engine The engine which the post process will be applied. (default: current engine)
  69857. * @param reusable If the post process can be reused on the same frame. (default: false)
  69858. * @param textureType Type of textures used when performing the post process. (default: 0)
  69859. * @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)
  69860. */
  69861. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69862. /** @hidden */
  69863. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  69864. }
  69865. }
  69866. declare module BABYLON {
  69867. /** @hidden */
  69868. export var highlightsPixelShader: {
  69869. name: string;
  69870. shader: string;
  69871. };
  69872. }
  69873. declare module BABYLON {
  69874. /**
  69875. * Extracts highlights from the image
  69876. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69877. */
  69878. export class HighlightsPostProcess extends PostProcess {
  69879. /**
  69880. * Gets a string identifying the name of the class
  69881. * @returns "HighlightsPostProcess" string
  69882. */
  69883. getClassName(): string;
  69884. /**
  69885. * Extracts highlights from the image
  69886. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69887. * @param name The name of the effect.
  69888. * @param options The required width/height ratio to downsize to before computing the render pass.
  69889. * @param camera The camera to apply the render pass to.
  69890. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69891. * @param engine The engine which the post process will be applied. (default: current engine)
  69892. * @param reusable If the post process can be reused on the same frame. (default: false)
  69893. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  69894. */
  69895. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69896. }
  69897. }
  69898. declare module BABYLON {
  69899. /** @hidden */
  69900. export var mrtFragmentDeclaration: {
  69901. name: string;
  69902. shader: string;
  69903. };
  69904. }
  69905. declare module BABYLON {
  69906. /** @hidden */
  69907. export var geometryPixelShader: {
  69908. name: string;
  69909. shader: string;
  69910. };
  69911. }
  69912. declare module BABYLON {
  69913. /** @hidden */
  69914. export var geometryVertexShader: {
  69915. name: string;
  69916. shader: string;
  69917. };
  69918. }
  69919. declare module BABYLON {
  69920. /** @hidden */
  69921. interface ISavedTransformationMatrix {
  69922. world: Matrix;
  69923. viewProjection: Matrix;
  69924. }
  69925. /**
  69926. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  69927. */
  69928. export class GeometryBufferRenderer {
  69929. /**
  69930. * Constant used to retrieve the position texture index in the G-Buffer textures array
  69931. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  69932. */
  69933. static readonly POSITION_TEXTURE_TYPE: number;
  69934. /**
  69935. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  69936. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  69937. */
  69938. static readonly VELOCITY_TEXTURE_TYPE: number;
  69939. /**
  69940. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  69941. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  69942. */
  69943. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  69944. /**
  69945. * Dictionary used to store the previous transformation matrices of each rendered mesh
  69946. * in order to compute objects velocities when enableVelocity is set to "true"
  69947. * @hidden
  69948. */
  69949. _previousTransformationMatrices: {
  69950. [index: number]: ISavedTransformationMatrix;
  69951. };
  69952. /**
  69953. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  69954. * in order to compute objects velocities when enableVelocity is set to "true"
  69955. * @hidden
  69956. */
  69957. _previousBonesTransformationMatrices: {
  69958. [index: number]: Float32Array;
  69959. };
  69960. /**
  69961. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  69962. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  69963. */
  69964. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  69965. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  69966. renderTransparentMeshes: boolean;
  69967. private _scene;
  69968. private _resizeObserver;
  69969. private _multiRenderTarget;
  69970. private _ratio;
  69971. private _enablePosition;
  69972. private _enableVelocity;
  69973. private _enableReflectivity;
  69974. private _positionIndex;
  69975. private _velocityIndex;
  69976. private _reflectivityIndex;
  69977. protected _effect: Effect;
  69978. protected _cachedDefines: string;
  69979. /**
  69980. * Set the render list (meshes to be rendered) used in the G buffer.
  69981. */
  69982. set renderList(meshes: Mesh[]);
  69983. /**
  69984. * Gets wether or not G buffer are supported by the running hardware.
  69985. * This requires draw buffer supports
  69986. */
  69987. get isSupported(): boolean;
  69988. /**
  69989. * Returns the index of the given texture type in the G-Buffer textures array
  69990. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  69991. * @returns the index of the given texture type in the G-Buffer textures array
  69992. */
  69993. getTextureIndex(textureType: number): number;
  69994. /**
  69995. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  69996. */
  69997. get enablePosition(): boolean;
  69998. /**
  69999. * Sets whether or not objects positions are enabled for the G buffer.
  70000. */
  70001. set enablePosition(enable: boolean);
  70002. /**
  70003. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  70004. */
  70005. get enableVelocity(): boolean;
  70006. /**
  70007. * Sets wether or not objects velocities are enabled for the G buffer.
  70008. */
  70009. set enableVelocity(enable: boolean);
  70010. /**
  70011. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  70012. */
  70013. get enableReflectivity(): boolean;
  70014. /**
  70015. * Sets wether or not objects roughness are enabled for the G buffer.
  70016. */
  70017. set enableReflectivity(enable: boolean);
  70018. /**
  70019. * Gets the scene associated with the buffer.
  70020. */
  70021. get scene(): Scene;
  70022. /**
  70023. * Gets the ratio used by the buffer during its creation.
  70024. * How big is the buffer related to the main canvas.
  70025. */
  70026. get ratio(): number;
  70027. /** @hidden */
  70028. static _SceneComponentInitialization: (scene: Scene) => void;
  70029. /**
  70030. * Creates a new G Buffer for the scene
  70031. * @param scene The scene the buffer belongs to
  70032. * @param ratio How big is the buffer related to the main canvas.
  70033. */
  70034. constructor(scene: Scene, ratio?: number);
  70035. /**
  70036. * Checks wether everything is ready to render a submesh to the G buffer.
  70037. * @param subMesh the submesh to check readiness for
  70038. * @param useInstances is the mesh drawn using instance or not
  70039. * @returns true if ready otherwise false
  70040. */
  70041. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70042. /**
  70043. * Gets the current underlying G Buffer.
  70044. * @returns the buffer
  70045. */
  70046. getGBuffer(): MultiRenderTarget;
  70047. /**
  70048. * Gets the number of samples used to render the buffer (anti aliasing).
  70049. */
  70050. get samples(): number;
  70051. /**
  70052. * Sets the number of samples used to render the buffer (anti aliasing).
  70053. */
  70054. set samples(value: number);
  70055. /**
  70056. * Disposes the renderer and frees up associated resources.
  70057. */
  70058. dispose(): void;
  70059. protected _createRenderTargets(): void;
  70060. private _copyBonesTransformationMatrices;
  70061. }
  70062. }
  70063. declare module BABYLON {
  70064. interface Scene {
  70065. /** @hidden (Backing field) */
  70066. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70067. /**
  70068. * Gets or Sets the current geometry buffer associated to the scene.
  70069. */
  70070. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70071. /**
  70072. * Enables a GeometryBufferRender and associates it with the scene
  70073. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  70074. * @returns the GeometryBufferRenderer
  70075. */
  70076. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  70077. /**
  70078. * Disables the GeometryBufferRender associated with the scene
  70079. */
  70080. disableGeometryBufferRenderer(): void;
  70081. }
  70082. /**
  70083. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  70084. * in several rendering techniques.
  70085. */
  70086. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  70087. /**
  70088. * The component name helpful to identify the component in the list of scene components.
  70089. */
  70090. readonly name: string;
  70091. /**
  70092. * The scene the component belongs to.
  70093. */
  70094. scene: Scene;
  70095. /**
  70096. * Creates a new instance of the component for the given scene
  70097. * @param scene Defines the scene to register the component in
  70098. */
  70099. constructor(scene: Scene);
  70100. /**
  70101. * Registers the component in a given scene
  70102. */
  70103. register(): void;
  70104. /**
  70105. * Rebuilds the elements related to this component in case of
  70106. * context lost for instance.
  70107. */
  70108. rebuild(): void;
  70109. /**
  70110. * Disposes the component and the associated ressources
  70111. */
  70112. dispose(): void;
  70113. private _gatherRenderTargets;
  70114. }
  70115. }
  70116. declare module BABYLON {
  70117. /** @hidden */
  70118. export var motionBlurPixelShader: {
  70119. name: string;
  70120. shader: string;
  70121. };
  70122. }
  70123. declare module BABYLON {
  70124. /**
  70125. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  70126. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  70127. * As an example, all you have to do is to create the post-process:
  70128. * var mb = new BABYLON.MotionBlurPostProcess(
  70129. * 'mb', // The name of the effect.
  70130. * scene, // The scene containing the objects to blur according to their velocity.
  70131. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  70132. * camera // The camera to apply the render pass to.
  70133. * );
  70134. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  70135. */
  70136. export class MotionBlurPostProcess extends PostProcess {
  70137. /**
  70138. * Defines how much the image is blurred by the movement. Default value is equal to 1
  70139. */
  70140. motionStrength: number;
  70141. /**
  70142. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  70143. */
  70144. get motionBlurSamples(): number;
  70145. /**
  70146. * Sets the number of iterations to be used for motion blur quality
  70147. */
  70148. set motionBlurSamples(samples: number);
  70149. private _motionBlurSamples;
  70150. private _geometryBufferRenderer;
  70151. /**
  70152. * Gets a string identifying the name of the class
  70153. * @returns "MotionBlurPostProcess" string
  70154. */
  70155. getClassName(): string;
  70156. /**
  70157. * Creates a new instance MotionBlurPostProcess
  70158. * @param name The name of the effect.
  70159. * @param scene The scene containing the objects to blur according to their velocity.
  70160. * @param options The required width/height ratio to downsize to before computing the render pass.
  70161. * @param camera The camera to apply the render pass to.
  70162. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70163. * @param engine The engine which the post process will be applied. (default: current engine)
  70164. * @param reusable If the post process can be reused on the same frame. (default: false)
  70165. * @param textureType Type of textures used when performing the post process. (default: 0)
  70166. * @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)
  70167. */
  70168. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70169. /**
  70170. * Excludes the given skinned mesh from computing bones velocities.
  70171. * 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.
  70172. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  70173. */
  70174. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70175. /**
  70176. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  70177. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  70178. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  70179. */
  70180. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70181. /**
  70182. * Disposes the post process.
  70183. * @param camera The camera to dispose the post process on.
  70184. */
  70185. dispose(camera?: Camera): void;
  70186. /** @hidden */
  70187. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  70188. }
  70189. }
  70190. declare module BABYLON {
  70191. /** @hidden */
  70192. export var refractionPixelShader: {
  70193. name: string;
  70194. shader: string;
  70195. };
  70196. }
  70197. declare module BABYLON {
  70198. /**
  70199. * Post process which applies a refractin texture
  70200. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70201. */
  70202. export class RefractionPostProcess extends PostProcess {
  70203. private _refTexture;
  70204. private _ownRefractionTexture;
  70205. /** the base color of the refraction (used to taint the rendering) */
  70206. color: Color3;
  70207. /** simulated refraction depth */
  70208. depth: number;
  70209. /** the coefficient of the base color (0 to remove base color tainting) */
  70210. colorLevel: number;
  70211. /** Gets the url used to load the refraction texture */
  70212. refractionTextureUrl: string;
  70213. /**
  70214. * Gets or sets the refraction texture
  70215. * Please note that you are responsible for disposing the texture if you set it manually
  70216. */
  70217. get refractionTexture(): Texture;
  70218. set refractionTexture(value: Texture);
  70219. /**
  70220. * Gets a string identifying the name of the class
  70221. * @returns "RefractionPostProcess" string
  70222. */
  70223. getClassName(): string;
  70224. /**
  70225. * Initializes the RefractionPostProcess
  70226. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70227. * @param name The name of the effect.
  70228. * @param refractionTextureUrl Url of the refraction texture to use
  70229. * @param color the base color of the refraction (used to taint the rendering)
  70230. * @param depth simulated refraction depth
  70231. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  70232. * @param camera The camera to apply the render pass to.
  70233. * @param options The required width/height ratio to downsize to before computing the render pass.
  70234. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70235. * @param engine The engine which the post process will be applied. (default: current engine)
  70236. * @param reusable If the post process can be reused on the same frame. (default: false)
  70237. */
  70238. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70239. /**
  70240. * Disposes of the post process
  70241. * @param camera Camera to dispose post process on
  70242. */
  70243. dispose(camera: Camera): void;
  70244. /** @hidden */
  70245. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  70246. }
  70247. }
  70248. declare module BABYLON {
  70249. /** @hidden */
  70250. export var sharpenPixelShader: {
  70251. name: string;
  70252. shader: string;
  70253. };
  70254. }
  70255. declare module BABYLON {
  70256. /**
  70257. * The SharpenPostProcess applies a sharpen kernel to every pixel
  70258. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70259. */
  70260. export class SharpenPostProcess extends PostProcess {
  70261. /**
  70262. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  70263. */
  70264. colorAmount: number;
  70265. /**
  70266. * How much sharpness should be applied (default: 0.3)
  70267. */
  70268. edgeAmount: number;
  70269. /**
  70270. * Gets a string identifying the name of the class
  70271. * @returns "SharpenPostProcess" string
  70272. */
  70273. getClassName(): string;
  70274. /**
  70275. * Creates a new instance ConvolutionPostProcess
  70276. * @param name The name of the effect.
  70277. * @param options The required width/height ratio to downsize to before computing the render pass.
  70278. * @param camera The camera to apply the render pass to.
  70279. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70280. * @param engine The engine which the post process will be applied. (default: current engine)
  70281. * @param reusable If the post process can be reused on the same frame. (default: false)
  70282. * @param textureType Type of textures used when performing the post process. (default: 0)
  70283. * @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)
  70284. */
  70285. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70286. /** @hidden */
  70287. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  70288. }
  70289. }
  70290. declare module BABYLON {
  70291. /**
  70292. * PostProcessRenderPipeline
  70293. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70294. */
  70295. export class PostProcessRenderPipeline {
  70296. private engine;
  70297. private _renderEffects;
  70298. private _renderEffectsForIsolatedPass;
  70299. /**
  70300. * List of inspectable custom properties (used by the Inspector)
  70301. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70302. */
  70303. inspectableCustomProperties: IInspectable[];
  70304. /**
  70305. * @hidden
  70306. */
  70307. protected _cameras: Camera[];
  70308. /** @hidden */
  70309. _name: string;
  70310. /**
  70311. * Gets pipeline name
  70312. */
  70313. get name(): string;
  70314. /** Gets the list of attached cameras */
  70315. get cameras(): Camera[];
  70316. /**
  70317. * Initializes a PostProcessRenderPipeline
  70318. * @param engine engine to add the pipeline to
  70319. * @param name name of the pipeline
  70320. */
  70321. constructor(engine: Engine, name: string);
  70322. /**
  70323. * Gets the class name
  70324. * @returns "PostProcessRenderPipeline"
  70325. */
  70326. getClassName(): string;
  70327. /**
  70328. * If all the render effects in the pipeline are supported
  70329. */
  70330. get isSupported(): boolean;
  70331. /**
  70332. * Adds an effect to the pipeline
  70333. * @param renderEffect the effect to add
  70334. */
  70335. addEffect(renderEffect: PostProcessRenderEffect): void;
  70336. /** @hidden */
  70337. _rebuild(): void;
  70338. /** @hidden */
  70339. _enableEffect(renderEffectName: string, cameras: Camera): void;
  70340. /** @hidden */
  70341. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  70342. /** @hidden */
  70343. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70344. /** @hidden */
  70345. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70346. /** @hidden */
  70347. _attachCameras(cameras: Camera, unique: boolean): void;
  70348. /** @hidden */
  70349. _attachCameras(cameras: Camera[], unique: boolean): void;
  70350. /** @hidden */
  70351. _detachCameras(cameras: Camera): void;
  70352. /** @hidden */
  70353. _detachCameras(cameras: Nullable<Camera[]>): void;
  70354. /** @hidden */
  70355. _update(): void;
  70356. /** @hidden */
  70357. _reset(): void;
  70358. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  70359. /**
  70360. * Sets the required values to the prepass renderer.
  70361. * @param prePassRenderer defines the prepass renderer to setup.
  70362. * @returns true if the pre pass is needed.
  70363. */
  70364. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  70365. /**
  70366. * Disposes of the pipeline
  70367. */
  70368. dispose(): void;
  70369. }
  70370. }
  70371. declare module BABYLON {
  70372. /**
  70373. * PostProcessRenderPipelineManager class
  70374. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70375. */
  70376. export class PostProcessRenderPipelineManager {
  70377. private _renderPipelines;
  70378. /**
  70379. * Initializes a PostProcessRenderPipelineManager
  70380. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70381. */
  70382. constructor();
  70383. /**
  70384. * Gets the list of supported render pipelines
  70385. */
  70386. get supportedPipelines(): PostProcessRenderPipeline[];
  70387. /**
  70388. * Adds a pipeline to the manager
  70389. * @param renderPipeline The pipeline to add
  70390. */
  70391. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  70392. /**
  70393. * Attaches a camera to the pipeline
  70394. * @param renderPipelineName The name of the pipeline to attach to
  70395. * @param cameras the camera to attach
  70396. * @param unique if the camera can be attached multiple times to the pipeline
  70397. */
  70398. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  70399. /**
  70400. * Detaches a camera from the pipeline
  70401. * @param renderPipelineName The name of the pipeline to detach from
  70402. * @param cameras the camera to detach
  70403. */
  70404. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  70405. /**
  70406. * Enables an effect by name on a pipeline
  70407. * @param renderPipelineName the name of the pipeline to enable the effect in
  70408. * @param renderEffectName the name of the effect to enable
  70409. * @param cameras the cameras that the effect should be enabled on
  70410. */
  70411. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70412. /**
  70413. * Disables an effect by name on a pipeline
  70414. * @param renderPipelineName the name of the pipeline to disable the effect in
  70415. * @param renderEffectName the name of the effect to disable
  70416. * @param cameras the cameras that the effect should be disabled on
  70417. */
  70418. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70419. /**
  70420. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  70421. */
  70422. update(): void;
  70423. /** @hidden */
  70424. _rebuild(): void;
  70425. /**
  70426. * Disposes of the manager and pipelines
  70427. */
  70428. dispose(): void;
  70429. }
  70430. }
  70431. declare module BABYLON {
  70432. interface Scene {
  70433. /** @hidden (Backing field) */
  70434. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70435. /**
  70436. * Gets the postprocess render pipeline manager
  70437. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70438. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70439. */
  70440. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70441. }
  70442. /**
  70443. * Defines the Render Pipeline scene component responsible to rendering pipelines
  70444. */
  70445. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  70446. /**
  70447. * The component name helpfull to identify the component in the list of scene components.
  70448. */
  70449. readonly name: string;
  70450. /**
  70451. * The scene the component belongs to.
  70452. */
  70453. scene: Scene;
  70454. /**
  70455. * Creates a new instance of the component for the given scene
  70456. * @param scene Defines the scene to register the component in
  70457. */
  70458. constructor(scene: Scene);
  70459. /**
  70460. * Registers the component in a given scene
  70461. */
  70462. register(): void;
  70463. /**
  70464. * Rebuilds the elements related to this component in case of
  70465. * context lost for instance.
  70466. */
  70467. rebuild(): void;
  70468. /**
  70469. * Disposes the component and the associated ressources
  70470. */
  70471. dispose(): void;
  70472. private _gatherRenderTargets;
  70473. }
  70474. }
  70475. declare module BABYLON {
  70476. /**
  70477. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  70478. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70479. */
  70480. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  70481. private _scene;
  70482. private _camerasToBeAttached;
  70483. /**
  70484. * ID of the sharpen post process,
  70485. */
  70486. private readonly SharpenPostProcessId;
  70487. /**
  70488. * @ignore
  70489. * ID of the image processing post process;
  70490. */
  70491. readonly ImageProcessingPostProcessId: string;
  70492. /**
  70493. * @ignore
  70494. * ID of the Fast Approximate Anti-Aliasing post process;
  70495. */
  70496. readonly FxaaPostProcessId: string;
  70497. /**
  70498. * ID of the chromatic aberration post process,
  70499. */
  70500. private readonly ChromaticAberrationPostProcessId;
  70501. /**
  70502. * ID of the grain post process
  70503. */
  70504. private readonly GrainPostProcessId;
  70505. /**
  70506. * Sharpen post process which will apply a sharpen convolution to enhance edges
  70507. */
  70508. sharpen: SharpenPostProcess;
  70509. private _sharpenEffect;
  70510. private bloom;
  70511. /**
  70512. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  70513. */
  70514. depthOfField: DepthOfFieldEffect;
  70515. /**
  70516. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  70517. */
  70518. fxaa: FxaaPostProcess;
  70519. /**
  70520. * Image post processing pass used to perform operations such as tone mapping or color grading.
  70521. */
  70522. imageProcessing: ImageProcessingPostProcess;
  70523. /**
  70524. * Chromatic aberration post process which will shift rgb colors in the image
  70525. */
  70526. chromaticAberration: ChromaticAberrationPostProcess;
  70527. private _chromaticAberrationEffect;
  70528. /**
  70529. * Grain post process which add noise to the image
  70530. */
  70531. grain: GrainPostProcess;
  70532. private _grainEffect;
  70533. /**
  70534. * Glow post process which adds a glow to emissive areas of the image
  70535. */
  70536. private _glowLayer;
  70537. /**
  70538. * Animations which can be used to tweak settings over a period of time
  70539. */
  70540. animations: Animation[];
  70541. private _imageProcessingConfigurationObserver;
  70542. private _sharpenEnabled;
  70543. private _bloomEnabled;
  70544. private _depthOfFieldEnabled;
  70545. private _depthOfFieldBlurLevel;
  70546. private _fxaaEnabled;
  70547. private _imageProcessingEnabled;
  70548. private _defaultPipelineTextureType;
  70549. private _bloomScale;
  70550. private _chromaticAberrationEnabled;
  70551. private _grainEnabled;
  70552. private _buildAllowed;
  70553. /**
  70554. * Gets active scene
  70555. */
  70556. get scene(): Scene;
  70557. /**
  70558. * Enable or disable the sharpen process from the pipeline
  70559. */
  70560. set sharpenEnabled(enabled: boolean);
  70561. get sharpenEnabled(): boolean;
  70562. private _resizeObserver;
  70563. private _hardwareScaleLevel;
  70564. private _bloomKernel;
  70565. /**
  70566. * Specifies the size of the bloom blur kernel, relative to the final output size
  70567. */
  70568. get bloomKernel(): number;
  70569. set bloomKernel(value: number);
  70570. /**
  70571. * Specifies the weight of the bloom in the final rendering
  70572. */
  70573. private _bloomWeight;
  70574. /**
  70575. * Specifies the luma threshold for the area that will be blurred by the bloom
  70576. */
  70577. private _bloomThreshold;
  70578. private _hdr;
  70579. /**
  70580. * The strength of the bloom.
  70581. */
  70582. set bloomWeight(value: number);
  70583. get bloomWeight(): number;
  70584. /**
  70585. * The strength of the bloom.
  70586. */
  70587. set bloomThreshold(value: number);
  70588. get bloomThreshold(): number;
  70589. /**
  70590. * The scale of the bloom, lower value will provide better performance.
  70591. */
  70592. set bloomScale(value: number);
  70593. get bloomScale(): number;
  70594. /**
  70595. * Enable or disable the bloom from the pipeline
  70596. */
  70597. set bloomEnabled(enabled: boolean);
  70598. get bloomEnabled(): boolean;
  70599. private _rebuildBloom;
  70600. /**
  70601. * If the depth of field is enabled.
  70602. */
  70603. get depthOfFieldEnabled(): boolean;
  70604. set depthOfFieldEnabled(enabled: boolean);
  70605. /**
  70606. * Blur level of the depth of field effect. (Higher blur will effect performance)
  70607. */
  70608. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  70609. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  70610. /**
  70611. * If the anti aliasing is enabled.
  70612. */
  70613. set fxaaEnabled(enabled: boolean);
  70614. get fxaaEnabled(): boolean;
  70615. private _samples;
  70616. /**
  70617. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70618. */
  70619. set samples(sampleCount: number);
  70620. get samples(): number;
  70621. /**
  70622. * If image processing is enabled.
  70623. */
  70624. set imageProcessingEnabled(enabled: boolean);
  70625. get imageProcessingEnabled(): boolean;
  70626. /**
  70627. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  70628. */
  70629. set glowLayerEnabled(enabled: boolean);
  70630. get glowLayerEnabled(): boolean;
  70631. /**
  70632. * Gets the glow layer (or null if not defined)
  70633. */
  70634. get glowLayer(): Nullable<GlowLayer>;
  70635. /**
  70636. * Enable or disable the chromaticAberration process from the pipeline
  70637. */
  70638. set chromaticAberrationEnabled(enabled: boolean);
  70639. get chromaticAberrationEnabled(): boolean;
  70640. /**
  70641. * Enable or disable the grain process from the pipeline
  70642. */
  70643. set grainEnabled(enabled: boolean);
  70644. get grainEnabled(): boolean;
  70645. /**
  70646. * @constructor
  70647. * @param name - The rendering pipeline name (default: "")
  70648. * @param hdr - If high dynamic range textures should be used (default: true)
  70649. * @param scene - The scene linked to this pipeline (default: the last created scene)
  70650. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  70651. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  70652. */
  70653. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  70654. /**
  70655. * Get the class name
  70656. * @returns "DefaultRenderingPipeline"
  70657. */
  70658. getClassName(): string;
  70659. /**
  70660. * Force the compilation of the entire pipeline.
  70661. */
  70662. prepare(): void;
  70663. private _hasCleared;
  70664. private _prevPostProcess;
  70665. private _prevPrevPostProcess;
  70666. private _setAutoClearAndTextureSharing;
  70667. private _depthOfFieldSceneObserver;
  70668. private _buildPipeline;
  70669. private _disposePostProcesses;
  70670. /**
  70671. * Adds a camera to the pipeline
  70672. * @param camera the camera to be added
  70673. */
  70674. addCamera(camera: Camera): void;
  70675. /**
  70676. * Removes a camera from the pipeline
  70677. * @param camera the camera to remove
  70678. */
  70679. removeCamera(camera: Camera): void;
  70680. /**
  70681. * Dispose of the pipeline and stop all post processes
  70682. */
  70683. dispose(): void;
  70684. /**
  70685. * Serialize the rendering pipeline (Used when exporting)
  70686. * @returns the serialized object
  70687. */
  70688. serialize(): any;
  70689. /**
  70690. * Parse the serialized pipeline
  70691. * @param source Source pipeline.
  70692. * @param scene The scene to load the pipeline to.
  70693. * @param rootUrl The URL of the serialized pipeline.
  70694. * @returns An instantiated pipeline from the serialized object.
  70695. */
  70696. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  70697. }
  70698. }
  70699. declare module BABYLON {
  70700. /** @hidden */
  70701. export var lensHighlightsPixelShader: {
  70702. name: string;
  70703. shader: string;
  70704. };
  70705. }
  70706. declare module BABYLON {
  70707. /** @hidden */
  70708. export var depthOfFieldPixelShader: {
  70709. name: string;
  70710. shader: string;
  70711. };
  70712. }
  70713. declare module BABYLON {
  70714. /**
  70715. * BABYLON.JS Chromatic Aberration GLSL Shader
  70716. * Author: Olivier Guyot
  70717. * Separates very slightly R, G and B colors on the edges of the screen
  70718. * Inspired by Francois Tarlier & Martins Upitis
  70719. */
  70720. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  70721. /**
  70722. * @ignore
  70723. * The chromatic aberration PostProcess id in the pipeline
  70724. */
  70725. LensChromaticAberrationEffect: string;
  70726. /**
  70727. * @ignore
  70728. * The highlights enhancing PostProcess id in the pipeline
  70729. */
  70730. HighlightsEnhancingEffect: string;
  70731. /**
  70732. * @ignore
  70733. * The depth-of-field PostProcess id in the pipeline
  70734. */
  70735. LensDepthOfFieldEffect: string;
  70736. private _scene;
  70737. private _depthTexture;
  70738. private _grainTexture;
  70739. private _chromaticAberrationPostProcess;
  70740. private _highlightsPostProcess;
  70741. private _depthOfFieldPostProcess;
  70742. private _edgeBlur;
  70743. private _grainAmount;
  70744. private _chromaticAberration;
  70745. private _distortion;
  70746. private _highlightsGain;
  70747. private _highlightsThreshold;
  70748. private _dofDistance;
  70749. private _dofAperture;
  70750. private _dofDarken;
  70751. private _dofPentagon;
  70752. private _blurNoise;
  70753. /**
  70754. * @constructor
  70755. *
  70756. * Effect parameters are as follow:
  70757. * {
  70758. * chromatic_aberration: number; // from 0 to x (1 for realism)
  70759. * edge_blur: number; // from 0 to x (1 for realism)
  70760. * distortion: number; // from 0 to x (1 for realism)
  70761. * grain_amount: number; // from 0 to 1
  70762. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  70763. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  70764. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  70765. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  70766. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  70767. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  70768. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  70769. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  70770. * }
  70771. * Note: if an effect parameter is unset, effect is disabled
  70772. *
  70773. * @param name The rendering pipeline name
  70774. * @param parameters - An object containing all parameters (see above)
  70775. * @param scene The scene linked to this pipeline
  70776. * @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)
  70777. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70778. */
  70779. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  70780. /**
  70781. * Get the class name
  70782. * @returns "LensRenderingPipeline"
  70783. */
  70784. getClassName(): string;
  70785. /**
  70786. * Gets associated scene
  70787. */
  70788. get scene(): Scene;
  70789. /**
  70790. * Gets or sets the edge blur
  70791. */
  70792. get edgeBlur(): number;
  70793. set edgeBlur(value: number);
  70794. /**
  70795. * Gets or sets the grain amount
  70796. */
  70797. get grainAmount(): number;
  70798. set grainAmount(value: number);
  70799. /**
  70800. * Gets or sets the chromatic aberration amount
  70801. */
  70802. get chromaticAberration(): number;
  70803. set chromaticAberration(value: number);
  70804. /**
  70805. * Gets or sets the depth of field aperture
  70806. */
  70807. get dofAperture(): number;
  70808. set dofAperture(value: number);
  70809. /**
  70810. * Gets or sets the edge distortion
  70811. */
  70812. get edgeDistortion(): number;
  70813. set edgeDistortion(value: number);
  70814. /**
  70815. * Gets or sets the depth of field distortion
  70816. */
  70817. get dofDistortion(): number;
  70818. set dofDistortion(value: number);
  70819. /**
  70820. * Gets or sets the darken out of focus amount
  70821. */
  70822. get darkenOutOfFocus(): number;
  70823. set darkenOutOfFocus(value: number);
  70824. /**
  70825. * Gets or sets a boolean indicating if blur noise is enabled
  70826. */
  70827. get blurNoise(): boolean;
  70828. set blurNoise(value: boolean);
  70829. /**
  70830. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  70831. */
  70832. get pentagonBokeh(): boolean;
  70833. set pentagonBokeh(value: boolean);
  70834. /**
  70835. * Gets or sets the highlight grain amount
  70836. */
  70837. get highlightsGain(): number;
  70838. set highlightsGain(value: number);
  70839. /**
  70840. * Gets or sets the highlight threshold
  70841. */
  70842. get highlightsThreshold(): number;
  70843. set highlightsThreshold(value: number);
  70844. /**
  70845. * Sets the amount of blur at the edges
  70846. * @param amount blur amount
  70847. */
  70848. setEdgeBlur(amount: number): void;
  70849. /**
  70850. * Sets edge blur to 0
  70851. */
  70852. disableEdgeBlur(): void;
  70853. /**
  70854. * Sets the amout of grain
  70855. * @param amount Amount of grain
  70856. */
  70857. setGrainAmount(amount: number): void;
  70858. /**
  70859. * Set grain amount to 0
  70860. */
  70861. disableGrain(): void;
  70862. /**
  70863. * Sets the chromatic aberration amount
  70864. * @param amount amount of chromatic aberration
  70865. */
  70866. setChromaticAberration(amount: number): void;
  70867. /**
  70868. * Sets chromatic aberration amount to 0
  70869. */
  70870. disableChromaticAberration(): void;
  70871. /**
  70872. * Sets the EdgeDistortion amount
  70873. * @param amount amount of EdgeDistortion
  70874. */
  70875. setEdgeDistortion(amount: number): void;
  70876. /**
  70877. * Sets edge distortion to 0
  70878. */
  70879. disableEdgeDistortion(): void;
  70880. /**
  70881. * Sets the FocusDistance amount
  70882. * @param amount amount of FocusDistance
  70883. */
  70884. setFocusDistance(amount: number): void;
  70885. /**
  70886. * Disables depth of field
  70887. */
  70888. disableDepthOfField(): void;
  70889. /**
  70890. * Sets the Aperture amount
  70891. * @param amount amount of Aperture
  70892. */
  70893. setAperture(amount: number): void;
  70894. /**
  70895. * Sets the DarkenOutOfFocus amount
  70896. * @param amount amount of DarkenOutOfFocus
  70897. */
  70898. setDarkenOutOfFocus(amount: number): void;
  70899. private _pentagonBokehIsEnabled;
  70900. /**
  70901. * Creates a pentagon bokeh effect
  70902. */
  70903. enablePentagonBokeh(): void;
  70904. /**
  70905. * Disables the pentagon bokeh effect
  70906. */
  70907. disablePentagonBokeh(): void;
  70908. /**
  70909. * Enables noise blur
  70910. */
  70911. enableNoiseBlur(): void;
  70912. /**
  70913. * Disables noise blur
  70914. */
  70915. disableNoiseBlur(): void;
  70916. /**
  70917. * Sets the HighlightsGain amount
  70918. * @param amount amount of HighlightsGain
  70919. */
  70920. setHighlightsGain(amount: number): void;
  70921. /**
  70922. * Sets the HighlightsThreshold amount
  70923. * @param amount amount of HighlightsThreshold
  70924. */
  70925. setHighlightsThreshold(amount: number): void;
  70926. /**
  70927. * Disables highlights
  70928. */
  70929. disableHighlights(): void;
  70930. /**
  70931. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  70932. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  70933. */
  70934. dispose(disableDepthRender?: boolean): void;
  70935. private _createChromaticAberrationPostProcess;
  70936. private _createHighlightsPostProcess;
  70937. private _createDepthOfFieldPostProcess;
  70938. private _createGrainTexture;
  70939. }
  70940. }
  70941. declare module BABYLON {
  70942. /**
  70943. * Contains all parameters needed for the prepass to perform
  70944. * screen space subsurface scattering
  70945. */
  70946. export class SSAO2Configuration implements PrePassEffectConfiguration {
  70947. /**
  70948. * Is subsurface enabled
  70949. */
  70950. enabled: boolean;
  70951. /**
  70952. * Name of the configuration
  70953. */
  70954. name: string;
  70955. /**
  70956. * Textures that should be present in the MRT for this effect to work
  70957. */
  70958. readonly texturesRequired: number[];
  70959. /**
  70960. * Builds a ssao2 configuration object
  70961. * @param scene The scene
  70962. */
  70963. constructor();
  70964. /**
  70965. * Disposes the configuration
  70966. */
  70967. dispose(): void;
  70968. }
  70969. }
  70970. declare module BABYLON {
  70971. /** @hidden */
  70972. export var ssao2PixelShader: {
  70973. name: string;
  70974. shader: string;
  70975. };
  70976. }
  70977. declare module BABYLON {
  70978. /** @hidden */
  70979. export var ssaoCombinePixelShader: {
  70980. name: string;
  70981. shader: string;
  70982. };
  70983. }
  70984. declare module BABYLON {
  70985. /**
  70986. * Render pipeline to produce ssao effect
  70987. */
  70988. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  70989. /**
  70990. * @ignore
  70991. * The PassPostProcess id in the pipeline that contains the original scene color
  70992. */
  70993. SSAOOriginalSceneColorEffect: string;
  70994. /**
  70995. * @ignore
  70996. * The SSAO PostProcess id in the pipeline
  70997. */
  70998. SSAORenderEffect: string;
  70999. /**
  71000. * @ignore
  71001. * The horizontal blur PostProcess id in the pipeline
  71002. */
  71003. SSAOBlurHRenderEffect: string;
  71004. /**
  71005. * @ignore
  71006. * The vertical blur PostProcess id in the pipeline
  71007. */
  71008. SSAOBlurVRenderEffect: string;
  71009. /**
  71010. * @ignore
  71011. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71012. */
  71013. SSAOCombineRenderEffect: string;
  71014. /**
  71015. * The output strength of the SSAO post-process. Default value is 1.0.
  71016. */
  71017. totalStrength: number;
  71018. /**
  71019. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  71020. */
  71021. maxZ: number;
  71022. /**
  71023. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  71024. */
  71025. minZAspect: number;
  71026. private _samples;
  71027. /**
  71028. * Number of samples used for the SSAO calculations. Default value is 8
  71029. */
  71030. set samples(n: number);
  71031. get samples(): number;
  71032. private _textureSamples;
  71033. /**
  71034. * Number of samples to use for antialiasing
  71035. */
  71036. set textureSamples(n: number);
  71037. get textureSamples(): number;
  71038. /**
  71039. * Force rendering the geometry through geometry buffer
  71040. */
  71041. private _forceGeometryBuffer;
  71042. /**
  71043. * Ratio object used for SSAO ratio and blur ratio
  71044. */
  71045. private _ratio;
  71046. /**
  71047. * Dynamically generated sphere sampler.
  71048. */
  71049. private _sampleSphere;
  71050. private _ssao2PrePassConfiguration;
  71051. /**
  71052. * Blur filter offsets
  71053. */
  71054. private _samplerOffsets;
  71055. private _expensiveBlur;
  71056. /**
  71057. * If bilateral blur should be used
  71058. */
  71059. set expensiveBlur(b: boolean);
  71060. get expensiveBlur(): boolean;
  71061. /**
  71062. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  71063. */
  71064. radius: number;
  71065. /**
  71066. * The base color of the SSAO post-process
  71067. * The final result is "base + ssao" between [0, 1]
  71068. */
  71069. base: number;
  71070. /**
  71071. * Support test.
  71072. */
  71073. static get IsSupported(): boolean;
  71074. private _scene;
  71075. private _randomTexture;
  71076. private _originalColorPostProcess;
  71077. private _ssaoPostProcess;
  71078. private _blurHPostProcess;
  71079. private _blurVPostProcess;
  71080. private _ssaoCombinePostProcess;
  71081. private _prePassRenderer;
  71082. /**
  71083. * Gets active scene
  71084. */
  71085. get scene(): Scene;
  71086. /**
  71087. * @constructor
  71088. * @param name The rendering pipeline name
  71089. * @param scene The scene linked to this pipeline
  71090. * @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 }
  71091. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71092. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  71093. */
  71094. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  71095. /**
  71096. * Get the class name
  71097. * @returns "SSAO2RenderingPipeline"
  71098. */
  71099. getClassName(): string;
  71100. /**
  71101. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71102. */
  71103. dispose(disableGeometryBufferRenderer?: boolean): void;
  71104. private _createBlurPostProcess;
  71105. /** @hidden */
  71106. _rebuild(): void;
  71107. private _bits;
  71108. private _radicalInverse_VdC;
  71109. private _hammersley;
  71110. private _hemisphereSample_uniform;
  71111. private _generateHemisphere;
  71112. private _getDefinesForSSAO;
  71113. private _createSSAOPostProcess;
  71114. private _createSSAOCombinePostProcess;
  71115. private _createRandomTexture;
  71116. /**
  71117. * Serialize the rendering pipeline (Used when exporting)
  71118. * @returns the serialized object
  71119. */
  71120. serialize(): any;
  71121. /**
  71122. * Parse the serialized pipeline
  71123. * @param source Source pipeline.
  71124. * @param scene The scene to load the pipeline to.
  71125. * @param rootUrl The URL of the serialized pipeline.
  71126. * @returns An instantiated pipeline from the serialized object.
  71127. */
  71128. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  71129. /**
  71130. * Sets the required values to the prepass renderer.
  71131. * @param prePassRenderer defines the prepass renderer to setup
  71132. * @returns true if the pre pass is needed.
  71133. */
  71134. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  71135. }
  71136. }
  71137. declare module BABYLON {
  71138. /** @hidden */
  71139. export var ssaoPixelShader: {
  71140. name: string;
  71141. shader: string;
  71142. };
  71143. }
  71144. declare module BABYLON {
  71145. /**
  71146. * Render pipeline to produce ssao effect
  71147. */
  71148. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  71149. /**
  71150. * @ignore
  71151. * The PassPostProcess id in the pipeline that contains the original scene color
  71152. */
  71153. SSAOOriginalSceneColorEffect: string;
  71154. /**
  71155. * @ignore
  71156. * The SSAO PostProcess id in the pipeline
  71157. */
  71158. SSAORenderEffect: string;
  71159. /**
  71160. * @ignore
  71161. * The horizontal blur PostProcess id in the pipeline
  71162. */
  71163. SSAOBlurHRenderEffect: string;
  71164. /**
  71165. * @ignore
  71166. * The vertical blur PostProcess id in the pipeline
  71167. */
  71168. SSAOBlurVRenderEffect: string;
  71169. /**
  71170. * @ignore
  71171. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71172. */
  71173. SSAOCombineRenderEffect: string;
  71174. /**
  71175. * The output strength of the SSAO post-process. Default value is 1.0.
  71176. */
  71177. totalStrength: number;
  71178. /**
  71179. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  71180. */
  71181. radius: number;
  71182. /**
  71183. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  71184. * Must not be equal to fallOff and superior to fallOff.
  71185. * Default value is 0.0075
  71186. */
  71187. area: number;
  71188. /**
  71189. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  71190. * Must not be equal to area and inferior to area.
  71191. * Default value is 0.000001
  71192. */
  71193. fallOff: number;
  71194. /**
  71195. * The base color of the SSAO post-process
  71196. * The final result is "base + ssao" between [0, 1]
  71197. */
  71198. base: number;
  71199. private _scene;
  71200. private _depthTexture;
  71201. private _randomTexture;
  71202. private _originalColorPostProcess;
  71203. private _ssaoPostProcess;
  71204. private _blurHPostProcess;
  71205. private _blurVPostProcess;
  71206. private _ssaoCombinePostProcess;
  71207. private _firstUpdate;
  71208. /**
  71209. * Gets active scene
  71210. */
  71211. get scene(): Scene;
  71212. /**
  71213. * @constructor
  71214. * @param name - The rendering pipeline name
  71215. * @param scene - The scene linked to this pipeline
  71216. * @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 }
  71217. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  71218. */
  71219. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  71220. /**
  71221. * Get the class name
  71222. * @returns "SSAORenderingPipeline"
  71223. */
  71224. getClassName(): string;
  71225. /**
  71226. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71227. */
  71228. dispose(disableDepthRender?: boolean): void;
  71229. private _createBlurPostProcess;
  71230. /** @hidden */
  71231. _rebuild(): void;
  71232. private _createSSAOPostProcess;
  71233. private _createSSAOCombinePostProcess;
  71234. private _createRandomTexture;
  71235. }
  71236. }
  71237. declare module BABYLON {
  71238. /** @hidden */
  71239. export var screenSpaceReflectionPixelShader: {
  71240. name: string;
  71241. shader: string;
  71242. };
  71243. }
  71244. declare module BABYLON {
  71245. /**
  71246. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  71247. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  71248. */
  71249. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  71250. /**
  71251. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  71252. */
  71253. threshold: number;
  71254. /**
  71255. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  71256. */
  71257. strength: number;
  71258. /**
  71259. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  71260. */
  71261. reflectionSpecularFalloffExponent: number;
  71262. /**
  71263. * 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]
  71264. */
  71265. step: number;
  71266. /**
  71267. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  71268. */
  71269. roughnessFactor: number;
  71270. private _geometryBufferRenderer;
  71271. private _enableSmoothReflections;
  71272. private _reflectionSamples;
  71273. private _smoothSteps;
  71274. /**
  71275. * Gets a string identifying the name of the class
  71276. * @returns "ScreenSpaceReflectionPostProcess" string
  71277. */
  71278. getClassName(): string;
  71279. /**
  71280. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  71281. * @param name The name of the effect.
  71282. * @param scene The scene containing the objects to calculate reflections.
  71283. * @param options The required width/height ratio to downsize to before computing the render pass.
  71284. * @param camera The camera to apply the render pass to.
  71285. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71286. * @param engine The engine which the post process will be applied. (default: current engine)
  71287. * @param reusable If the post process can be reused on the same frame. (default: false)
  71288. * @param textureType Type of textures used when performing the post process. (default: 0)
  71289. * @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)
  71290. */
  71291. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71292. /**
  71293. * Gets wether or not smoothing reflections is enabled.
  71294. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71295. */
  71296. get enableSmoothReflections(): boolean;
  71297. /**
  71298. * Sets wether or not smoothing reflections is enabled.
  71299. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71300. */
  71301. set enableSmoothReflections(enabled: boolean);
  71302. /**
  71303. * Gets the number of samples taken while computing reflections. More samples count is high,
  71304. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71305. */
  71306. get reflectionSamples(): number;
  71307. /**
  71308. * Sets the number of samples taken while computing reflections. More samples count is high,
  71309. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71310. */
  71311. set reflectionSamples(samples: number);
  71312. /**
  71313. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  71314. * more the post-process will require GPU power and can generate a drop in FPS.
  71315. * Default value (5.0) work pretty well in all cases but can be adjusted.
  71316. */
  71317. get smoothSteps(): number;
  71318. set smoothSteps(steps: number);
  71319. private _updateEffectDefines;
  71320. /** @hidden */
  71321. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  71322. }
  71323. }
  71324. declare module BABYLON {
  71325. /** @hidden */
  71326. export var standardPixelShader: {
  71327. name: string;
  71328. shader: string;
  71329. };
  71330. }
  71331. declare module BABYLON {
  71332. /**
  71333. * Standard rendering pipeline
  71334. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71335. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  71336. */
  71337. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71338. /**
  71339. * Public members
  71340. */
  71341. /**
  71342. * Post-process which contains the original scene color before the pipeline applies all the effects
  71343. */
  71344. originalPostProcess: Nullable<PostProcess>;
  71345. /**
  71346. * Post-process used to down scale an image x4
  71347. */
  71348. downSampleX4PostProcess: Nullable<PostProcess>;
  71349. /**
  71350. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  71351. */
  71352. brightPassPostProcess: Nullable<PostProcess>;
  71353. /**
  71354. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  71355. */
  71356. blurHPostProcesses: PostProcess[];
  71357. /**
  71358. * Post-process array storing all the vertical blur post-processes used by the pipeline
  71359. */
  71360. blurVPostProcesses: PostProcess[];
  71361. /**
  71362. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  71363. */
  71364. textureAdderPostProcess: Nullable<PostProcess>;
  71365. /**
  71366. * Post-process used to create volumetric lighting effect
  71367. */
  71368. volumetricLightPostProcess: Nullable<PostProcess>;
  71369. /**
  71370. * Post-process used to smooth the previous volumetric light post-process on the X axis
  71371. */
  71372. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  71373. /**
  71374. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  71375. */
  71376. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  71377. /**
  71378. * Post-process used to merge the volumetric light effect and the real scene color
  71379. */
  71380. volumetricLightMergePostProces: Nullable<PostProcess>;
  71381. /**
  71382. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  71383. */
  71384. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  71385. /**
  71386. * Base post-process used to calculate the average luminance of the final image for HDR
  71387. */
  71388. luminancePostProcess: Nullable<PostProcess>;
  71389. /**
  71390. * Post-processes used to create down sample post-processes in order to get
  71391. * the average luminance of the final image for HDR
  71392. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  71393. */
  71394. luminanceDownSamplePostProcesses: PostProcess[];
  71395. /**
  71396. * Post-process used to create a HDR effect (light adaptation)
  71397. */
  71398. hdrPostProcess: Nullable<PostProcess>;
  71399. /**
  71400. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  71401. */
  71402. textureAdderFinalPostProcess: Nullable<PostProcess>;
  71403. /**
  71404. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  71405. */
  71406. lensFlareFinalPostProcess: Nullable<PostProcess>;
  71407. /**
  71408. * Post-process used to merge the final HDR post-process and the real scene color
  71409. */
  71410. hdrFinalPostProcess: Nullable<PostProcess>;
  71411. /**
  71412. * Post-process used to create a lens flare effect
  71413. */
  71414. lensFlarePostProcess: Nullable<PostProcess>;
  71415. /**
  71416. * Post-process that merges the result of the lens flare post-process and the real scene color
  71417. */
  71418. lensFlareComposePostProcess: Nullable<PostProcess>;
  71419. /**
  71420. * Post-process used to create a motion blur effect
  71421. */
  71422. motionBlurPostProcess: Nullable<PostProcess>;
  71423. /**
  71424. * Post-process used to create a depth of field effect
  71425. */
  71426. depthOfFieldPostProcess: Nullable<PostProcess>;
  71427. /**
  71428. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71429. */
  71430. fxaaPostProcess: Nullable<FxaaPostProcess>;
  71431. /**
  71432. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  71433. */
  71434. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  71435. /**
  71436. * Represents the brightness threshold in order to configure the illuminated surfaces
  71437. */
  71438. brightThreshold: number;
  71439. /**
  71440. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  71441. */
  71442. blurWidth: number;
  71443. /**
  71444. * Sets if the blur for highlighted surfaces must be only horizontal
  71445. */
  71446. horizontalBlur: boolean;
  71447. /**
  71448. * Gets the overall exposure used by the pipeline
  71449. */
  71450. get exposure(): number;
  71451. /**
  71452. * Sets the overall exposure used by the pipeline
  71453. */
  71454. set exposure(value: number);
  71455. /**
  71456. * Texture used typically to simulate "dirty" on camera lens
  71457. */
  71458. lensTexture: Nullable<Texture>;
  71459. /**
  71460. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  71461. */
  71462. volumetricLightCoefficient: number;
  71463. /**
  71464. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  71465. */
  71466. volumetricLightPower: number;
  71467. /**
  71468. * Used the set the blur intensity to smooth the volumetric lights
  71469. */
  71470. volumetricLightBlurScale: number;
  71471. /**
  71472. * Light (spot or directional) used to generate the volumetric lights rays
  71473. * The source light must have a shadow generate so the pipeline can get its
  71474. * depth map
  71475. */
  71476. sourceLight: Nullable<SpotLight | DirectionalLight>;
  71477. /**
  71478. * For eye adaptation, represents the minimum luminance the eye can see
  71479. */
  71480. hdrMinimumLuminance: number;
  71481. /**
  71482. * For eye adaptation, represents the decrease luminance speed
  71483. */
  71484. hdrDecreaseRate: number;
  71485. /**
  71486. * For eye adaptation, represents the increase luminance speed
  71487. */
  71488. hdrIncreaseRate: number;
  71489. /**
  71490. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71491. */
  71492. get hdrAutoExposure(): boolean;
  71493. /**
  71494. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71495. */
  71496. set hdrAutoExposure(value: boolean);
  71497. /**
  71498. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  71499. */
  71500. lensColorTexture: Nullable<Texture>;
  71501. /**
  71502. * The overall strengh for the lens flare effect
  71503. */
  71504. lensFlareStrength: number;
  71505. /**
  71506. * Dispersion coefficient for lens flare ghosts
  71507. */
  71508. lensFlareGhostDispersal: number;
  71509. /**
  71510. * Main lens flare halo width
  71511. */
  71512. lensFlareHaloWidth: number;
  71513. /**
  71514. * Based on the lens distortion effect, defines how much the lens flare result
  71515. * is distorted
  71516. */
  71517. lensFlareDistortionStrength: number;
  71518. /**
  71519. * Configures the blur intensity used for for lens flare (halo)
  71520. */
  71521. lensFlareBlurWidth: number;
  71522. /**
  71523. * Lens star texture must be used to simulate rays on the flares and is available
  71524. * in the documentation
  71525. */
  71526. lensStarTexture: Nullable<Texture>;
  71527. /**
  71528. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  71529. * flare effect by taking account of the dirt texture
  71530. */
  71531. lensFlareDirtTexture: Nullable<Texture>;
  71532. /**
  71533. * Represents the focal length for the depth of field effect
  71534. */
  71535. depthOfFieldDistance: number;
  71536. /**
  71537. * Represents the blur intensity for the blurred part of the depth of field effect
  71538. */
  71539. depthOfFieldBlurWidth: number;
  71540. /**
  71541. * Gets how much the image is blurred by the movement while using the motion blur post-process
  71542. */
  71543. get motionStrength(): number;
  71544. /**
  71545. * Sets how much the image is blurred by the movement while using the motion blur post-process
  71546. */
  71547. set motionStrength(strength: number);
  71548. /**
  71549. * Gets wether or not the motion blur post-process is object based or screen based.
  71550. */
  71551. get objectBasedMotionBlur(): boolean;
  71552. /**
  71553. * Sets wether or not the motion blur post-process should be object based or screen based
  71554. */
  71555. set objectBasedMotionBlur(value: boolean);
  71556. /**
  71557. * List of animations for the pipeline (IAnimatable implementation)
  71558. */
  71559. animations: Animation[];
  71560. /**
  71561. * Private members
  71562. */
  71563. private _scene;
  71564. private _currentDepthOfFieldSource;
  71565. private _basePostProcess;
  71566. private _fixedExposure;
  71567. private _currentExposure;
  71568. private _hdrAutoExposure;
  71569. private _hdrCurrentLuminance;
  71570. private _motionStrength;
  71571. private _isObjectBasedMotionBlur;
  71572. private _floatTextureType;
  71573. private _camerasToBeAttached;
  71574. private _ratio;
  71575. private _bloomEnabled;
  71576. private _depthOfFieldEnabled;
  71577. private _vlsEnabled;
  71578. private _lensFlareEnabled;
  71579. private _hdrEnabled;
  71580. private _motionBlurEnabled;
  71581. private _fxaaEnabled;
  71582. private _screenSpaceReflectionsEnabled;
  71583. private _motionBlurSamples;
  71584. private _volumetricLightStepsCount;
  71585. private _samples;
  71586. /**
  71587. * @ignore
  71588. * Specifies if the bloom pipeline is enabled
  71589. */
  71590. get BloomEnabled(): boolean;
  71591. set BloomEnabled(enabled: boolean);
  71592. /**
  71593. * @ignore
  71594. * Specifies if the depth of field pipeline is enabed
  71595. */
  71596. get DepthOfFieldEnabled(): boolean;
  71597. set DepthOfFieldEnabled(enabled: boolean);
  71598. /**
  71599. * @ignore
  71600. * Specifies if the lens flare pipeline is enabed
  71601. */
  71602. get LensFlareEnabled(): boolean;
  71603. set LensFlareEnabled(enabled: boolean);
  71604. /**
  71605. * @ignore
  71606. * Specifies if the HDR pipeline is enabled
  71607. */
  71608. get HDREnabled(): boolean;
  71609. set HDREnabled(enabled: boolean);
  71610. /**
  71611. * @ignore
  71612. * Specifies if the volumetric lights scattering effect is enabled
  71613. */
  71614. get VLSEnabled(): boolean;
  71615. set VLSEnabled(enabled: boolean);
  71616. /**
  71617. * @ignore
  71618. * Specifies if the motion blur effect is enabled
  71619. */
  71620. get MotionBlurEnabled(): boolean;
  71621. set MotionBlurEnabled(enabled: boolean);
  71622. /**
  71623. * Specifies if anti-aliasing is enabled
  71624. */
  71625. get fxaaEnabled(): boolean;
  71626. set fxaaEnabled(enabled: boolean);
  71627. /**
  71628. * Specifies if screen space reflections are enabled.
  71629. */
  71630. get screenSpaceReflectionsEnabled(): boolean;
  71631. set screenSpaceReflectionsEnabled(enabled: boolean);
  71632. /**
  71633. * Specifies the number of steps used to calculate the volumetric lights
  71634. * Typically in interval [50, 200]
  71635. */
  71636. get volumetricLightStepsCount(): number;
  71637. set volumetricLightStepsCount(count: number);
  71638. /**
  71639. * Specifies the number of samples used for the motion blur effect
  71640. * Typically in interval [16, 64]
  71641. */
  71642. get motionBlurSamples(): number;
  71643. set motionBlurSamples(samples: number);
  71644. /**
  71645. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  71646. */
  71647. get samples(): number;
  71648. set samples(sampleCount: number);
  71649. /**
  71650. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71651. * @constructor
  71652. * @param name The rendering pipeline name
  71653. * @param scene The scene linked to this pipeline
  71654. * @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)
  71655. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  71656. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71657. */
  71658. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  71659. private _buildPipeline;
  71660. private _createDownSampleX4PostProcess;
  71661. private _createBrightPassPostProcess;
  71662. private _createBlurPostProcesses;
  71663. private _createTextureAdderPostProcess;
  71664. private _createVolumetricLightPostProcess;
  71665. private _createLuminancePostProcesses;
  71666. private _createHdrPostProcess;
  71667. private _createLensFlarePostProcess;
  71668. private _createDepthOfFieldPostProcess;
  71669. private _createMotionBlurPostProcess;
  71670. private _getDepthTexture;
  71671. private _disposePostProcesses;
  71672. /**
  71673. * Dispose of the pipeline and stop all post processes
  71674. */
  71675. dispose(): void;
  71676. /**
  71677. * Serialize the rendering pipeline (Used when exporting)
  71678. * @returns the serialized object
  71679. */
  71680. serialize(): any;
  71681. /**
  71682. * Parse the serialized pipeline
  71683. * @param source Source pipeline.
  71684. * @param scene The scene to load the pipeline to.
  71685. * @param rootUrl The URL of the serialized pipeline.
  71686. * @returns An instantiated pipeline from the serialized object.
  71687. */
  71688. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  71689. /**
  71690. * Luminance steps
  71691. */
  71692. static LuminanceSteps: number;
  71693. }
  71694. }
  71695. declare module BABYLON {
  71696. /** @hidden */
  71697. export var stereoscopicInterlacePixelShader: {
  71698. name: string;
  71699. shader: string;
  71700. };
  71701. }
  71702. declare module BABYLON {
  71703. /**
  71704. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  71705. */
  71706. export class StereoscopicInterlacePostProcessI extends PostProcess {
  71707. private _stepSize;
  71708. private _passedProcess;
  71709. /**
  71710. * Gets a string identifying the name of the class
  71711. * @returns "StereoscopicInterlacePostProcessI" string
  71712. */
  71713. getClassName(): string;
  71714. /**
  71715. * Initializes a StereoscopicInterlacePostProcessI
  71716. * @param name The name of the effect.
  71717. * @param rigCameras The rig cameras to be appled to the post process
  71718. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  71719. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  71720. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71721. * @param engine The engine which the post process will be applied. (default: current engine)
  71722. * @param reusable If the post process can be reused on the same frame. (default: false)
  71723. */
  71724. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71725. }
  71726. /**
  71727. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  71728. */
  71729. export class StereoscopicInterlacePostProcess extends PostProcess {
  71730. private _stepSize;
  71731. private _passedProcess;
  71732. /**
  71733. * Gets a string identifying the name of the class
  71734. * @returns "StereoscopicInterlacePostProcess" string
  71735. */
  71736. getClassName(): string;
  71737. /**
  71738. * Initializes a StereoscopicInterlacePostProcess
  71739. * @param name The name of the effect.
  71740. * @param rigCameras The rig cameras to be appled to the post process
  71741. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  71742. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71743. * @param engine The engine which the post process will be applied. (default: current engine)
  71744. * @param reusable If the post process can be reused on the same frame. (default: false)
  71745. */
  71746. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71747. }
  71748. }
  71749. declare module BABYLON {
  71750. /** @hidden */
  71751. export var tonemapPixelShader: {
  71752. name: string;
  71753. shader: string;
  71754. };
  71755. }
  71756. declare module BABYLON {
  71757. /** Defines operator used for tonemapping */
  71758. export enum TonemappingOperator {
  71759. /** Hable */
  71760. Hable = 0,
  71761. /** Reinhard */
  71762. Reinhard = 1,
  71763. /** HejiDawson */
  71764. HejiDawson = 2,
  71765. /** Photographic */
  71766. Photographic = 3
  71767. }
  71768. /**
  71769. * Defines a post process to apply tone mapping
  71770. */
  71771. export class TonemapPostProcess extends PostProcess {
  71772. private _operator;
  71773. /** Defines the required exposure adjustement */
  71774. exposureAdjustment: number;
  71775. /**
  71776. * Gets a string identifying the name of the class
  71777. * @returns "TonemapPostProcess" string
  71778. */
  71779. getClassName(): string;
  71780. /**
  71781. * Creates a new TonemapPostProcess
  71782. * @param name defines the name of the postprocess
  71783. * @param _operator defines the operator to use
  71784. * @param exposureAdjustment defines the required exposure adjustement
  71785. * @param camera defines the camera to use (can be null)
  71786. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  71787. * @param engine defines the hosting engine (can be ignore if camera is set)
  71788. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71789. */
  71790. constructor(name: string, _operator: TonemappingOperator,
  71791. /** Defines the required exposure adjustement */
  71792. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  71793. }
  71794. }
  71795. declare module BABYLON {
  71796. /** @hidden */
  71797. export var volumetricLightScatteringPixelShader: {
  71798. name: string;
  71799. shader: string;
  71800. };
  71801. }
  71802. declare module BABYLON {
  71803. /** @hidden */
  71804. export var volumetricLightScatteringPassVertexShader: {
  71805. name: string;
  71806. shader: string;
  71807. };
  71808. }
  71809. declare module BABYLON {
  71810. /** @hidden */
  71811. export var volumetricLightScatteringPassPixelShader: {
  71812. name: string;
  71813. shader: string;
  71814. };
  71815. }
  71816. declare module BABYLON {
  71817. /**
  71818. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  71819. */
  71820. export class VolumetricLightScatteringPostProcess extends PostProcess {
  71821. private _volumetricLightScatteringPass;
  71822. private _volumetricLightScatteringRTT;
  71823. private _viewPort;
  71824. private _screenCoordinates;
  71825. private _cachedDefines;
  71826. /**
  71827. * If not undefined, the mesh position is computed from the attached node position
  71828. */
  71829. attachedNode: {
  71830. position: Vector3;
  71831. };
  71832. /**
  71833. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  71834. */
  71835. customMeshPosition: Vector3;
  71836. /**
  71837. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  71838. */
  71839. useCustomMeshPosition: boolean;
  71840. /**
  71841. * If the post-process should inverse the light scattering direction
  71842. */
  71843. invert: boolean;
  71844. /**
  71845. * The internal mesh used by the post-process
  71846. */
  71847. mesh: Mesh;
  71848. /**
  71849. * @hidden
  71850. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  71851. */
  71852. get useDiffuseColor(): boolean;
  71853. set useDiffuseColor(useDiffuseColor: boolean);
  71854. /**
  71855. * Array containing the excluded meshes not rendered in the internal pass
  71856. */
  71857. excludedMeshes: AbstractMesh[];
  71858. /**
  71859. * Controls the overall intensity of the post-process
  71860. */
  71861. exposure: number;
  71862. /**
  71863. * Dissipates each sample's contribution in range [0, 1]
  71864. */
  71865. decay: number;
  71866. /**
  71867. * Controls the overall intensity of each sample
  71868. */
  71869. weight: number;
  71870. /**
  71871. * Controls the density of each sample
  71872. */
  71873. density: number;
  71874. /**
  71875. * @constructor
  71876. * @param name The post-process name
  71877. * @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)
  71878. * @param camera The camera that the post-process will be attached to
  71879. * @param mesh The mesh used to create the light scattering
  71880. * @param samples The post-process quality, default 100
  71881. * @param samplingModeThe post-process filtering mode
  71882. * @param engine The babylon engine
  71883. * @param reusable If the post-process is reusable
  71884. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  71885. */
  71886. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  71887. /**
  71888. * Returns the string "VolumetricLightScatteringPostProcess"
  71889. * @returns "VolumetricLightScatteringPostProcess"
  71890. */
  71891. getClassName(): string;
  71892. private _isReady;
  71893. /**
  71894. * Sets the new light position for light scattering effect
  71895. * @param position The new custom light position
  71896. */
  71897. setCustomMeshPosition(position: Vector3): void;
  71898. /**
  71899. * Returns the light position for light scattering effect
  71900. * @return Vector3 The custom light position
  71901. */
  71902. getCustomMeshPosition(): Vector3;
  71903. /**
  71904. * Disposes the internal assets and detaches the post-process from the camera
  71905. */
  71906. dispose(camera: Camera): void;
  71907. /**
  71908. * Returns the render target texture used by the post-process
  71909. * @return the render target texture used by the post-process
  71910. */
  71911. getPass(): RenderTargetTexture;
  71912. private _meshExcluded;
  71913. private _createPass;
  71914. private _updateMeshScreenCoordinates;
  71915. /**
  71916. * Creates a default mesh for the Volumeric Light Scattering post-process
  71917. * @param name The mesh name
  71918. * @param scene The scene where to create the mesh
  71919. * @return the default mesh
  71920. */
  71921. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  71922. }
  71923. }
  71924. declare module BABYLON {
  71925. /** @hidden */
  71926. export var screenSpaceCurvaturePixelShader: {
  71927. name: string;
  71928. shader: string;
  71929. };
  71930. }
  71931. declare module BABYLON {
  71932. /**
  71933. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  71934. */
  71935. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  71936. /**
  71937. * Defines how much ridge the curvature effect displays.
  71938. */
  71939. ridge: number;
  71940. /**
  71941. * Defines how much valley the curvature effect displays.
  71942. */
  71943. valley: number;
  71944. private _geometryBufferRenderer;
  71945. /**
  71946. * Gets a string identifying the name of the class
  71947. * @returns "ScreenSpaceCurvaturePostProcess" string
  71948. */
  71949. getClassName(): string;
  71950. /**
  71951. * Creates a new instance ScreenSpaceCurvaturePostProcess
  71952. * @param name The name of the effect.
  71953. * @param scene The scene containing the objects to blur according to their velocity.
  71954. * @param options The required width/height ratio to downsize to before computing the render pass.
  71955. * @param camera The camera to apply the render pass to.
  71956. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71957. * @param engine The engine which the post process will be applied. (default: current engine)
  71958. * @param reusable If the post process can be reused on the same frame. (default: false)
  71959. * @param textureType Type of textures used when performing the post process. (default: 0)
  71960. * @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)
  71961. */
  71962. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71963. /**
  71964. * Support test.
  71965. */
  71966. static get IsSupported(): boolean;
  71967. /** @hidden */
  71968. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  71969. }
  71970. }
  71971. declare module BABYLON {
  71972. interface Scene {
  71973. /** @hidden (Backing field) */
  71974. _boundingBoxRenderer: BoundingBoxRenderer;
  71975. /** @hidden (Backing field) */
  71976. _forceShowBoundingBoxes: boolean;
  71977. /**
  71978. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  71979. */
  71980. forceShowBoundingBoxes: boolean;
  71981. /**
  71982. * Gets the bounding box renderer associated with the scene
  71983. * @returns a BoundingBoxRenderer
  71984. */
  71985. getBoundingBoxRenderer(): BoundingBoxRenderer;
  71986. }
  71987. interface AbstractMesh {
  71988. /** @hidden (Backing field) */
  71989. _showBoundingBox: boolean;
  71990. /**
  71991. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  71992. */
  71993. showBoundingBox: boolean;
  71994. }
  71995. /**
  71996. * Component responsible of rendering the bounding box of the meshes in a scene.
  71997. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  71998. */
  71999. export class BoundingBoxRenderer implements ISceneComponent {
  72000. /**
  72001. * The component name helpfull to identify the component in the list of scene components.
  72002. */
  72003. readonly name: string;
  72004. /**
  72005. * The scene the component belongs to.
  72006. */
  72007. scene: Scene;
  72008. /**
  72009. * Color of the bounding box lines placed in front of an object
  72010. */
  72011. frontColor: Color3;
  72012. /**
  72013. * Color of the bounding box lines placed behind an object
  72014. */
  72015. backColor: Color3;
  72016. /**
  72017. * Defines if the renderer should show the back lines or not
  72018. */
  72019. showBackLines: boolean;
  72020. /**
  72021. * Observable raised before rendering a bounding box
  72022. */
  72023. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  72024. /**
  72025. * Observable raised after rendering a bounding box
  72026. */
  72027. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  72028. /**
  72029. * @hidden
  72030. */
  72031. renderList: SmartArray<BoundingBox>;
  72032. private _colorShader;
  72033. private _vertexBuffers;
  72034. private _indexBuffer;
  72035. private _fillIndexBuffer;
  72036. private _fillIndexData;
  72037. /**
  72038. * Instantiates a new bounding box renderer in a scene.
  72039. * @param scene the scene the renderer renders in
  72040. */
  72041. constructor(scene: Scene);
  72042. /**
  72043. * Registers the component in a given scene
  72044. */
  72045. register(): void;
  72046. private _evaluateSubMesh;
  72047. private _activeMesh;
  72048. private _prepareRessources;
  72049. private _createIndexBuffer;
  72050. /**
  72051. * Rebuilds the elements related to this component in case of
  72052. * context lost for instance.
  72053. */
  72054. rebuild(): void;
  72055. /**
  72056. * @hidden
  72057. */
  72058. reset(): void;
  72059. /**
  72060. * Render the bounding boxes of a specific rendering group
  72061. * @param renderingGroupId defines the rendering group to render
  72062. */
  72063. render(renderingGroupId: number): void;
  72064. /**
  72065. * In case of occlusion queries, we can render the occlusion bounding box through this method
  72066. * @param mesh Define the mesh to render the occlusion bounding box for
  72067. */
  72068. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  72069. /**
  72070. * Dispose and release the resources attached to this renderer.
  72071. */
  72072. dispose(): void;
  72073. }
  72074. }
  72075. declare module BABYLON {
  72076. interface Scene {
  72077. /** @hidden (Backing field) */
  72078. _depthRenderer: {
  72079. [id: string]: DepthRenderer;
  72080. };
  72081. /**
  72082. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  72083. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  72084. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  72085. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  72086. * @returns the created depth renderer
  72087. */
  72088. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  72089. /**
  72090. * Disables a depth renderer for a given camera
  72091. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  72092. */
  72093. disableDepthRenderer(camera?: Nullable<Camera>): void;
  72094. }
  72095. /**
  72096. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  72097. * in several rendering techniques.
  72098. */
  72099. export class DepthRendererSceneComponent implements ISceneComponent {
  72100. /**
  72101. * The component name helpfull to identify the component in the list of scene components.
  72102. */
  72103. readonly name: string;
  72104. /**
  72105. * The scene the component belongs to.
  72106. */
  72107. scene: Scene;
  72108. /**
  72109. * Creates a new instance of the component for the given scene
  72110. * @param scene Defines the scene to register the component in
  72111. */
  72112. constructor(scene: Scene);
  72113. /**
  72114. * Registers the component in a given scene
  72115. */
  72116. register(): void;
  72117. /**
  72118. * Rebuilds the elements related to this component in case of
  72119. * context lost for instance.
  72120. */
  72121. rebuild(): void;
  72122. /**
  72123. * Disposes the component and the associated ressources
  72124. */
  72125. dispose(): void;
  72126. private _gatherRenderTargets;
  72127. private _gatherActiveCameraRenderTargets;
  72128. }
  72129. }
  72130. declare module BABYLON {
  72131. interface AbstractScene {
  72132. /** @hidden (Backing field) */
  72133. _prePassRenderer: Nullable<PrePassRenderer>;
  72134. /**
  72135. * Gets or Sets the current prepass renderer associated to the scene.
  72136. */
  72137. prePassRenderer: Nullable<PrePassRenderer>;
  72138. /**
  72139. * Enables the prepass and associates it with the scene
  72140. * @returns the PrePassRenderer
  72141. */
  72142. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  72143. /**
  72144. * Disables the prepass associated with the scene
  72145. */
  72146. disablePrePassRenderer(): void;
  72147. }
  72148. /**
  72149. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  72150. * in several rendering techniques.
  72151. */
  72152. export class PrePassRendererSceneComponent implements ISceneComponent {
  72153. /**
  72154. * The component name helpful to identify the component in the list of scene components.
  72155. */
  72156. readonly name: string;
  72157. /**
  72158. * The scene the component belongs to.
  72159. */
  72160. scene: Scene;
  72161. /**
  72162. * Creates a new instance of the component for the given scene
  72163. * @param scene Defines the scene to register the component in
  72164. */
  72165. constructor(scene: Scene);
  72166. /**
  72167. * Registers the component in a given scene
  72168. */
  72169. register(): void;
  72170. private _beforeCameraDraw;
  72171. private _afterCameraDraw;
  72172. private _beforeClearStage;
  72173. /**
  72174. * Rebuilds the elements related to this component in case of
  72175. * context lost for instance.
  72176. */
  72177. rebuild(): void;
  72178. /**
  72179. * Disposes the component and the associated ressources
  72180. */
  72181. dispose(): void;
  72182. }
  72183. }
  72184. declare module BABYLON {
  72185. /** @hidden */
  72186. export var fibonacci: {
  72187. name: string;
  72188. shader: string;
  72189. };
  72190. }
  72191. declare module BABYLON {
  72192. /** @hidden */
  72193. export var diffusionProfile: {
  72194. name: string;
  72195. shader: string;
  72196. };
  72197. }
  72198. declare module BABYLON {
  72199. /** @hidden */
  72200. export var subSurfaceScatteringPixelShader: {
  72201. name: string;
  72202. shader: string;
  72203. };
  72204. }
  72205. declare module BABYLON {
  72206. /**
  72207. * Sub surface scattering post process
  72208. */
  72209. export class SubSurfaceScatteringPostProcess extends PostProcess {
  72210. /**
  72211. * Gets a string identifying the name of the class
  72212. * @returns "SubSurfaceScatteringPostProcess" string
  72213. */
  72214. getClassName(): string;
  72215. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72216. }
  72217. }
  72218. declare module BABYLON {
  72219. /**
  72220. * Contains all parameters needed for the prepass to perform
  72221. * screen space subsurface scattering
  72222. */
  72223. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  72224. /** @hidden */
  72225. static _SceneComponentInitialization: (scene: Scene) => void;
  72226. private _ssDiffusionS;
  72227. private _ssFilterRadii;
  72228. private _ssDiffusionD;
  72229. /**
  72230. * Post process to attach for screen space subsurface scattering
  72231. */
  72232. postProcess: SubSurfaceScatteringPostProcess;
  72233. /**
  72234. * Diffusion profile color for subsurface scattering
  72235. */
  72236. get ssDiffusionS(): number[];
  72237. /**
  72238. * Diffusion profile max color channel value for subsurface scattering
  72239. */
  72240. get ssDiffusionD(): number[];
  72241. /**
  72242. * Diffusion profile filter radius for subsurface scattering
  72243. */
  72244. get ssFilterRadii(): number[];
  72245. /**
  72246. * Is subsurface enabled
  72247. */
  72248. enabled: boolean;
  72249. /**
  72250. * Name of the configuration
  72251. */
  72252. name: string;
  72253. /**
  72254. * Diffusion profile colors for subsurface scattering
  72255. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  72256. * See ...
  72257. * Note that you can only store up to 5 of them
  72258. */
  72259. ssDiffusionProfileColors: Color3[];
  72260. /**
  72261. * Defines the ratio real world => scene units.
  72262. * Used for subsurface scattering
  72263. */
  72264. metersPerUnit: number;
  72265. /**
  72266. * Textures that should be present in the MRT for this effect to work
  72267. */
  72268. readonly texturesRequired: number[];
  72269. private _scene;
  72270. /**
  72271. * Builds a subsurface configuration object
  72272. * @param scene The scene
  72273. */
  72274. constructor(scene: Scene);
  72275. /**
  72276. * Adds a new diffusion profile.
  72277. * Useful for more realistic subsurface scattering on diverse materials.
  72278. * @param color The color of the diffusion profile. Should be the average color of the material.
  72279. * @return The index of the diffusion profile for the material subsurface configuration
  72280. */
  72281. addDiffusionProfile(color: Color3): number;
  72282. /**
  72283. * Creates the sss post process
  72284. * @return The created post process
  72285. */
  72286. createPostProcess(): SubSurfaceScatteringPostProcess;
  72287. /**
  72288. * Deletes all diffusion profiles.
  72289. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  72290. */
  72291. clearAllDiffusionProfiles(): void;
  72292. /**
  72293. * Disposes this object
  72294. */
  72295. dispose(): void;
  72296. /**
  72297. * @hidden
  72298. * https://zero-radiance.github.io/post/sampling-diffusion/
  72299. *
  72300. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  72301. * ------------------------------------------------------------------------------------
  72302. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  72303. * PDF[r, phi, s] = r * R[r, phi, s]
  72304. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  72305. * ------------------------------------------------------------------------------------
  72306. * We importance sample the color channel with the widest scattering distance.
  72307. */
  72308. getDiffusionProfileParameters(color: Color3): number;
  72309. /**
  72310. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  72311. * 'u' is the random number (the value of the CDF): [0, 1).
  72312. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  72313. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  72314. */
  72315. private _sampleBurleyDiffusionProfile;
  72316. }
  72317. }
  72318. declare module BABYLON {
  72319. interface AbstractScene {
  72320. /** @hidden (Backing field) */
  72321. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  72322. /**
  72323. * Gets or Sets the current prepass renderer associated to the scene.
  72324. */
  72325. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  72326. /**
  72327. * Enables the subsurface effect for prepass
  72328. * @returns the SubSurfaceConfiguration
  72329. */
  72330. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  72331. /**
  72332. * Disables the subsurface effect for prepass
  72333. */
  72334. disableSubSurfaceForPrePass(): void;
  72335. }
  72336. /**
  72337. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  72338. * in several rendering techniques.
  72339. */
  72340. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  72341. /**
  72342. * The component name helpful to identify the component in the list of scene components.
  72343. */
  72344. readonly name: string;
  72345. /**
  72346. * The scene the component belongs to.
  72347. */
  72348. scene: Scene;
  72349. /**
  72350. * Creates a new instance of the component for the given scene
  72351. * @param scene Defines the scene to register the component in
  72352. */
  72353. constructor(scene: Scene);
  72354. /**
  72355. * Registers the component in a given scene
  72356. */
  72357. register(): void;
  72358. /**
  72359. * Serializes the component data to the specified json object
  72360. * @param serializationObject The object to serialize to
  72361. */
  72362. serialize(serializationObject: any): void;
  72363. /**
  72364. * Adds all the elements from the container to the scene
  72365. * @param container the container holding the elements
  72366. */
  72367. addFromContainer(container: AbstractScene): void;
  72368. /**
  72369. * Removes all the elements in the container from the scene
  72370. * @param container contains the elements to remove
  72371. * @param dispose if the removed element should be disposed (default: false)
  72372. */
  72373. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  72374. /**
  72375. * Rebuilds the elements related to this component in case of
  72376. * context lost for instance.
  72377. */
  72378. rebuild(): void;
  72379. /**
  72380. * Disposes the component and the associated ressources
  72381. */
  72382. dispose(): void;
  72383. }
  72384. }
  72385. declare module BABYLON {
  72386. /** @hidden */
  72387. export var outlinePixelShader: {
  72388. name: string;
  72389. shader: string;
  72390. };
  72391. }
  72392. declare module BABYLON {
  72393. /** @hidden */
  72394. export var outlineVertexShader: {
  72395. name: string;
  72396. shader: string;
  72397. };
  72398. }
  72399. declare module BABYLON {
  72400. interface Scene {
  72401. /** @hidden */
  72402. _outlineRenderer: OutlineRenderer;
  72403. /**
  72404. * Gets the outline renderer associated with the scene
  72405. * @returns a OutlineRenderer
  72406. */
  72407. getOutlineRenderer(): OutlineRenderer;
  72408. }
  72409. interface AbstractMesh {
  72410. /** @hidden (Backing field) */
  72411. _renderOutline: boolean;
  72412. /**
  72413. * Gets or sets a boolean indicating if the outline must be rendered as well
  72414. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  72415. */
  72416. renderOutline: boolean;
  72417. /** @hidden (Backing field) */
  72418. _renderOverlay: boolean;
  72419. /**
  72420. * Gets or sets a boolean indicating if the overlay must be rendered as well
  72421. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  72422. */
  72423. renderOverlay: boolean;
  72424. }
  72425. /**
  72426. * This class is responsible to draw bothe outline/overlay of meshes.
  72427. * It should not be used directly but through the available method on mesh.
  72428. */
  72429. export class OutlineRenderer implements ISceneComponent {
  72430. /**
  72431. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  72432. */
  72433. private static _StencilReference;
  72434. /**
  72435. * The name of the component. Each component must have a unique name.
  72436. */
  72437. name: string;
  72438. /**
  72439. * The scene the component belongs to.
  72440. */
  72441. scene: Scene;
  72442. /**
  72443. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  72444. */
  72445. zOffset: number;
  72446. private _engine;
  72447. private _effect;
  72448. private _cachedDefines;
  72449. private _savedDepthWrite;
  72450. /**
  72451. * Instantiates a new outline renderer. (There could be only one per scene).
  72452. * @param scene Defines the scene it belongs to
  72453. */
  72454. constructor(scene: Scene);
  72455. /**
  72456. * Register the component to one instance of a scene.
  72457. */
  72458. register(): void;
  72459. /**
  72460. * Rebuilds the elements related to this component in case of
  72461. * context lost for instance.
  72462. */
  72463. rebuild(): void;
  72464. /**
  72465. * Disposes the component and the associated ressources.
  72466. */
  72467. dispose(): void;
  72468. /**
  72469. * Renders the outline in the canvas.
  72470. * @param subMesh Defines the sumesh to render
  72471. * @param batch Defines the batch of meshes in case of instances
  72472. * @param useOverlay Defines if the rendering is for the overlay or the outline
  72473. */
  72474. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  72475. /**
  72476. * Returns whether or not the outline renderer is ready for a given submesh.
  72477. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  72478. * @param subMesh Defines the submesh to check readyness for
  72479. * @param useInstances Defines wheter wee are trying to render instances or not
  72480. * @returns true if ready otherwise false
  72481. */
  72482. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72483. private _beforeRenderingMesh;
  72484. private _afterRenderingMesh;
  72485. }
  72486. }
  72487. declare module BABYLON {
  72488. /**
  72489. * Defines the basic options interface of a Sprite Frame Source Size.
  72490. */
  72491. export interface ISpriteJSONSpriteSourceSize {
  72492. /**
  72493. * number of the original width of the Frame
  72494. */
  72495. w: number;
  72496. /**
  72497. * number of the original height of the Frame
  72498. */
  72499. h: number;
  72500. }
  72501. /**
  72502. * Defines the basic options interface of a Sprite Frame Data.
  72503. */
  72504. export interface ISpriteJSONSpriteFrameData {
  72505. /**
  72506. * number of the x offset of the Frame
  72507. */
  72508. x: number;
  72509. /**
  72510. * number of the y offset of the Frame
  72511. */
  72512. y: number;
  72513. /**
  72514. * number of the width of the Frame
  72515. */
  72516. w: number;
  72517. /**
  72518. * number of the height of the Frame
  72519. */
  72520. h: number;
  72521. }
  72522. /**
  72523. * Defines the basic options interface of a JSON Sprite.
  72524. */
  72525. export interface ISpriteJSONSprite {
  72526. /**
  72527. * string name of the Frame
  72528. */
  72529. filename: string;
  72530. /**
  72531. * ISpriteJSONSpriteFrame basic object of the frame data
  72532. */
  72533. frame: ISpriteJSONSpriteFrameData;
  72534. /**
  72535. * boolean to flag is the frame was rotated.
  72536. */
  72537. rotated: boolean;
  72538. /**
  72539. * boolean to flag is the frame was trimmed.
  72540. */
  72541. trimmed: boolean;
  72542. /**
  72543. * ISpriteJSONSpriteFrame basic object of the source data
  72544. */
  72545. spriteSourceSize: ISpriteJSONSpriteFrameData;
  72546. /**
  72547. * ISpriteJSONSpriteFrame basic object of the source data
  72548. */
  72549. sourceSize: ISpriteJSONSpriteSourceSize;
  72550. }
  72551. /**
  72552. * Defines the basic options interface of a JSON atlas.
  72553. */
  72554. export interface ISpriteJSONAtlas {
  72555. /**
  72556. * Array of objects that contain the frame data.
  72557. */
  72558. frames: Array<ISpriteJSONSprite>;
  72559. /**
  72560. * object basic object containing the sprite meta data.
  72561. */
  72562. meta?: object;
  72563. }
  72564. }
  72565. declare module BABYLON {
  72566. /** @hidden */
  72567. export var spriteMapPixelShader: {
  72568. name: string;
  72569. shader: string;
  72570. };
  72571. }
  72572. declare module BABYLON {
  72573. /** @hidden */
  72574. export var spriteMapVertexShader: {
  72575. name: string;
  72576. shader: string;
  72577. };
  72578. }
  72579. declare module BABYLON {
  72580. /**
  72581. * Defines the basic options interface of a SpriteMap
  72582. */
  72583. export interface ISpriteMapOptions {
  72584. /**
  72585. * Vector2 of the number of cells in the grid.
  72586. */
  72587. stageSize?: Vector2;
  72588. /**
  72589. * Vector2 of the size of the output plane in World Units.
  72590. */
  72591. outputSize?: Vector2;
  72592. /**
  72593. * Vector3 of the position of the output plane in World Units.
  72594. */
  72595. outputPosition?: Vector3;
  72596. /**
  72597. * Vector3 of the rotation of the output plane.
  72598. */
  72599. outputRotation?: Vector3;
  72600. /**
  72601. * number of layers that the system will reserve in resources.
  72602. */
  72603. layerCount?: number;
  72604. /**
  72605. * number of max animation frames a single cell will reserve in resources.
  72606. */
  72607. maxAnimationFrames?: number;
  72608. /**
  72609. * number cell index of the base tile when the system compiles.
  72610. */
  72611. baseTile?: number;
  72612. /**
  72613. * boolean flip the sprite after its been repositioned by the framing data.
  72614. */
  72615. flipU?: boolean;
  72616. /**
  72617. * Vector3 scalar of the global RGB values of the SpriteMap.
  72618. */
  72619. colorMultiply?: Vector3;
  72620. }
  72621. /**
  72622. * Defines the IDisposable interface in order to be cleanable from resources.
  72623. */
  72624. export interface ISpriteMap extends IDisposable {
  72625. /**
  72626. * String name of the SpriteMap.
  72627. */
  72628. name: string;
  72629. /**
  72630. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  72631. */
  72632. atlasJSON: ISpriteJSONAtlas;
  72633. /**
  72634. * Texture of the SpriteMap.
  72635. */
  72636. spriteSheet: Texture;
  72637. /**
  72638. * The parameters to initialize the SpriteMap with.
  72639. */
  72640. options: ISpriteMapOptions;
  72641. }
  72642. /**
  72643. * Class used to manage a grid restricted sprite deployment on an Output plane.
  72644. */
  72645. export class SpriteMap implements ISpriteMap {
  72646. /** The Name of the spriteMap */
  72647. name: string;
  72648. /** The JSON file with the frame and meta data */
  72649. atlasJSON: ISpriteJSONAtlas;
  72650. /** The systems Sprite Sheet Texture */
  72651. spriteSheet: Texture;
  72652. /** Arguments passed with the Constructor */
  72653. options: ISpriteMapOptions;
  72654. /** Public Sprite Storage array, parsed from atlasJSON */
  72655. sprites: Array<ISpriteJSONSprite>;
  72656. /** Returns the Number of Sprites in the System */
  72657. get spriteCount(): number;
  72658. /** Returns the Position of Output Plane*/
  72659. get position(): Vector3;
  72660. /** Returns the Position of Output Plane*/
  72661. set position(v: Vector3);
  72662. /** Returns the Rotation of Output Plane*/
  72663. get rotation(): Vector3;
  72664. /** Returns the Rotation of Output Plane*/
  72665. set rotation(v: Vector3);
  72666. /** Sets the AnimationMap*/
  72667. get animationMap(): RawTexture;
  72668. /** Sets the AnimationMap*/
  72669. set animationMap(v: RawTexture);
  72670. /** Scene that the SpriteMap was created in */
  72671. private _scene;
  72672. /** Texture Buffer of Float32 that holds tile frame data*/
  72673. private _frameMap;
  72674. /** Texture Buffers of Float32 that holds tileMap data*/
  72675. private _tileMaps;
  72676. /** Texture Buffer of Float32 that holds Animation Data*/
  72677. private _animationMap;
  72678. /** Custom ShaderMaterial Central to the System*/
  72679. private _material;
  72680. /** Custom ShaderMaterial Central to the System*/
  72681. private _output;
  72682. /** Systems Time Ticker*/
  72683. private _time;
  72684. /**
  72685. * Creates a new SpriteMap
  72686. * @param name defines the SpriteMaps Name
  72687. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  72688. * @param spriteSheet is the Texture that the Sprites are on.
  72689. * @param options a basic deployment configuration
  72690. * @param scene The Scene that the map is deployed on
  72691. */
  72692. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  72693. /**
  72694. * Returns tileID location
  72695. * @returns Vector2 the cell position ID
  72696. */
  72697. getTileID(): Vector2;
  72698. /**
  72699. * Gets the UV location of the mouse over the SpriteMap.
  72700. * @returns Vector2 the UV position of the mouse interaction
  72701. */
  72702. getMousePosition(): Vector2;
  72703. /**
  72704. * Creates the "frame" texture Buffer
  72705. * -------------------------------------
  72706. * Structure of frames
  72707. * "filename": "Falling-Water-2.png",
  72708. * "frame": {"x":69,"y":103,"w":24,"h":32},
  72709. * "rotated": true,
  72710. * "trimmed": true,
  72711. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  72712. * "sourceSize": {"w":32,"h":32}
  72713. * @returns RawTexture of the frameMap
  72714. */
  72715. private _createFrameBuffer;
  72716. /**
  72717. * Creates the tileMap texture Buffer
  72718. * @param buffer normally and array of numbers, or a false to generate from scratch
  72719. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  72720. * @returns RawTexture of the tileMap
  72721. */
  72722. private _createTileBuffer;
  72723. /**
  72724. * Modifies the data of the tileMaps
  72725. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  72726. * @param pos is the iVector2 Coordinates of the Tile
  72727. * @param tile The SpriteIndex of the new Tile
  72728. */
  72729. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  72730. /**
  72731. * Creates the animationMap texture Buffer
  72732. * @param buffer normally and array of numbers, or a false to generate from scratch
  72733. * @returns RawTexture of the animationMap
  72734. */
  72735. private _createTileAnimationBuffer;
  72736. /**
  72737. * Modifies the data of the animationMap
  72738. * @param cellID is the Index of the Sprite
  72739. * @param _frame is the target Animation frame
  72740. * @param toCell is the Target Index of the next frame of the animation
  72741. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  72742. * @param speed is a global scalar of the time variable on the map.
  72743. */
  72744. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  72745. /**
  72746. * Exports the .tilemaps file
  72747. */
  72748. saveTileMaps(): void;
  72749. /**
  72750. * Imports the .tilemaps file
  72751. * @param url of the .tilemaps file
  72752. */
  72753. loadTileMaps(url: string): void;
  72754. /**
  72755. * Release associated resources
  72756. */
  72757. dispose(): void;
  72758. }
  72759. }
  72760. declare module BABYLON {
  72761. /**
  72762. * Class used to manage multiple sprites of different sizes on the same spritesheet
  72763. * @see https://doc.babylonjs.com/babylon101/sprites
  72764. */
  72765. export class SpritePackedManager extends SpriteManager {
  72766. /** defines the packed manager's name */
  72767. name: string;
  72768. /**
  72769. * Creates a new sprite manager from a packed sprite sheet
  72770. * @param name defines the manager's name
  72771. * @param imgUrl defines the sprite sheet url
  72772. * @param capacity defines the maximum allowed number of sprites
  72773. * @param scene defines the hosting scene
  72774. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  72775. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  72776. * @param samplingMode defines the smapling mode to use with spritesheet
  72777. * @param fromPacked set to true; do not alter
  72778. */
  72779. constructor(
  72780. /** defines the packed manager's name */
  72781. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  72782. }
  72783. }
  72784. declare module BABYLON {
  72785. /**
  72786. * Defines the list of states available for a task inside a AssetsManager
  72787. */
  72788. export enum AssetTaskState {
  72789. /**
  72790. * Initialization
  72791. */
  72792. INIT = 0,
  72793. /**
  72794. * Running
  72795. */
  72796. RUNNING = 1,
  72797. /**
  72798. * Done
  72799. */
  72800. DONE = 2,
  72801. /**
  72802. * Error
  72803. */
  72804. ERROR = 3
  72805. }
  72806. /**
  72807. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  72808. */
  72809. export abstract class AbstractAssetTask {
  72810. /**
  72811. * Task name
  72812. */ name: string;
  72813. /**
  72814. * Callback called when the task is successful
  72815. */
  72816. onSuccess: (task: any) => void;
  72817. /**
  72818. * Callback called when the task is not successful
  72819. */
  72820. onError: (task: any, message?: string, exception?: any) => void;
  72821. /**
  72822. * Creates a new AssetsManager
  72823. * @param name defines the name of the task
  72824. */
  72825. constructor(
  72826. /**
  72827. * Task name
  72828. */ name: string);
  72829. private _isCompleted;
  72830. private _taskState;
  72831. private _errorObject;
  72832. /**
  72833. * Get if the task is completed
  72834. */
  72835. get isCompleted(): boolean;
  72836. /**
  72837. * Gets the current state of the task
  72838. */
  72839. get taskState(): AssetTaskState;
  72840. /**
  72841. * Gets the current error object (if task is in error)
  72842. */
  72843. get errorObject(): {
  72844. message?: string;
  72845. exception?: any;
  72846. };
  72847. /**
  72848. * Internal only
  72849. * @hidden
  72850. */
  72851. _setErrorObject(message?: string, exception?: any): void;
  72852. /**
  72853. * Execute the current task
  72854. * @param scene defines the scene where you want your assets to be loaded
  72855. * @param onSuccess is a callback called when the task is successfully executed
  72856. * @param onError is a callback called if an error occurs
  72857. */
  72858. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72859. /**
  72860. * Execute the current task
  72861. * @param scene defines the scene where you want your assets to be loaded
  72862. * @param onSuccess is a callback called when the task is successfully executed
  72863. * @param onError is a callback called if an error occurs
  72864. */
  72865. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72866. /**
  72867. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  72868. * This can be used with failed tasks that have the reason for failure fixed.
  72869. */
  72870. reset(): void;
  72871. private onErrorCallback;
  72872. private onDoneCallback;
  72873. }
  72874. /**
  72875. * Define the interface used by progress events raised during assets loading
  72876. */
  72877. export interface IAssetsProgressEvent {
  72878. /**
  72879. * Defines the number of remaining tasks to process
  72880. */
  72881. remainingCount: number;
  72882. /**
  72883. * Defines the total number of tasks
  72884. */
  72885. totalCount: number;
  72886. /**
  72887. * Defines the task that was just processed
  72888. */
  72889. task: AbstractAssetTask;
  72890. }
  72891. /**
  72892. * Class used to share progress information about assets loading
  72893. */
  72894. export class AssetsProgressEvent implements IAssetsProgressEvent {
  72895. /**
  72896. * Defines the number of remaining tasks to process
  72897. */
  72898. remainingCount: number;
  72899. /**
  72900. * Defines the total number of tasks
  72901. */
  72902. totalCount: number;
  72903. /**
  72904. * Defines the task that was just processed
  72905. */
  72906. task: AbstractAssetTask;
  72907. /**
  72908. * Creates a AssetsProgressEvent
  72909. * @param remainingCount defines the number of remaining tasks to process
  72910. * @param totalCount defines the total number of tasks
  72911. * @param task defines the task that was just processed
  72912. */
  72913. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  72914. }
  72915. /**
  72916. * Define a task used by AssetsManager to load assets into a container
  72917. */
  72918. export class ContainerAssetTask extends AbstractAssetTask {
  72919. /**
  72920. * Defines the name of the task
  72921. */
  72922. name: string;
  72923. /**
  72924. * Defines the list of mesh's names you want to load
  72925. */
  72926. meshesNames: any;
  72927. /**
  72928. * Defines the root url to use as a base to load your meshes and associated resources
  72929. */
  72930. rootUrl: string;
  72931. /**
  72932. * Defines the filename or File of the scene to load from
  72933. */
  72934. sceneFilename: string | File;
  72935. /**
  72936. * Get the loaded asset container
  72937. */
  72938. loadedContainer: AssetContainer;
  72939. /**
  72940. * Gets the list of loaded meshes
  72941. */
  72942. loadedMeshes: Array<AbstractMesh>;
  72943. /**
  72944. * Gets the list of loaded particle systems
  72945. */
  72946. loadedParticleSystems: Array<IParticleSystem>;
  72947. /**
  72948. * Gets the list of loaded skeletons
  72949. */
  72950. loadedSkeletons: Array<Skeleton>;
  72951. /**
  72952. * Gets the list of loaded animation groups
  72953. */
  72954. loadedAnimationGroups: Array<AnimationGroup>;
  72955. /**
  72956. * Callback called when the task is successful
  72957. */
  72958. onSuccess: (task: ContainerAssetTask) => void;
  72959. /**
  72960. * Callback called when the task is successful
  72961. */
  72962. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  72963. /**
  72964. * Creates a new ContainerAssetTask
  72965. * @param name defines the name of the task
  72966. * @param meshesNames defines the list of mesh's names you want to load
  72967. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  72968. * @param sceneFilename defines the filename or File of the scene to load from
  72969. */
  72970. constructor(
  72971. /**
  72972. * Defines the name of the task
  72973. */
  72974. name: string,
  72975. /**
  72976. * Defines the list of mesh's names you want to load
  72977. */
  72978. meshesNames: any,
  72979. /**
  72980. * Defines the root url to use as a base to load your meshes and associated resources
  72981. */
  72982. rootUrl: string,
  72983. /**
  72984. * Defines the filename or File of the scene to load from
  72985. */
  72986. sceneFilename: string | File);
  72987. /**
  72988. * Execute the current task
  72989. * @param scene defines the scene where you want your assets to be loaded
  72990. * @param onSuccess is a callback called when the task is successfully executed
  72991. * @param onError is a callback called if an error occurs
  72992. */
  72993. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72994. }
  72995. /**
  72996. * Define a task used by AssetsManager to load meshes
  72997. */
  72998. export class MeshAssetTask extends AbstractAssetTask {
  72999. /**
  73000. * Defines the name of the task
  73001. */
  73002. name: string;
  73003. /**
  73004. * Defines the list of mesh's names you want to load
  73005. */
  73006. meshesNames: any;
  73007. /**
  73008. * Defines the root url to use as a base to load your meshes and associated resources
  73009. */
  73010. rootUrl: string;
  73011. /**
  73012. * Defines the filename or File of the scene to load from
  73013. */
  73014. sceneFilename: string | File;
  73015. /**
  73016. * Gets the list of loaded meshes
  73017. */
  73018. loadedMeshes: Array<AbstractMesh>;
  73019. /**
  73020. * Gets the list of loaded particle systems
  73021. */
  73022. loadedParticleSystems: Array<IParticleSystem>;
  73023. /**
  73024. * Gets the list of loaded skeletons
  73025. */
  73026. loadedSkeletons: Array<Skeleton>;
  73027. /**
  73028. * Gets the list of loaded animation groups
  73029. */
  73030. loadedAnimationGroups: Array<AnimationGroup>;
  73031. /**
  73032. * Callback called when the task is successful
  73033. */
  73034. onSuccess: (task: MeshAssetTask) => void;
  73035. /**
  73036. * Callback called when the task is successful
  73037. */
  73038. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  73039. /**
  73040. * Creates a new MeshAssetTask
  73041. * @param name defines the name of the task
  73042. * @param meshesNames defines the list of mesh's names you want to load
  73043. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  73044. * @param sceneFilename defines the filename or File of the scene to load from
  73045. */
  73046. constructor(
  73047. /**
  73048. * Defines the name of the task
  73049. */
  73050. name: string,
  73051. /**
  73052. * Defines the list of mesh's names you want to load
  73053. */
  73054. meshesNames: any,
  73055. /**
  73056. * Defines the root url to use as a base to load your meshes and associated resources
  73057. */
  73058. rootUrl: string,
  73059. /**
  73060. * Defines the filename or File of the scene to load from
  73061. */
  73062. sceneFilename: string | File);
  73063. /**
  73064. * Execute the current task
  73065. * @param scene defines the scene where you want your assets to be loaded
  73066. * @param onSuccess is a callback called when the task is successfully executed
  73067. * @param onError is a callback called if an error occurs
  73068. */
  73069. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73070. }
  73071. /**
  73072. * Define a task used by AssetsManager to load text content
  73073. */
  73074. export class TextFileAssetTask extends AbstractAssetTask {
  73075. /**
  73076. * Defines the name of the task
  73077. */
  73078. name: string;
  73079. /**
  73080. * Defines the location of the file to load
  73081. */
  73082. url: string;
  73083. /**
  73084. * Gets the loaded text string
  73085. */
  73086. text: string;
  73087. /**
  73088. * Callback called when the task is successful
  73089. */
  73090. onSuccess: (task: TextFileAssetTask) => void;
  73091. /**
  73092. * Callback called when the task is successful
  73093. */
  73094. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  73095. /**
  73096. * Creates a new TextFileAssetTask object
  73097. * @param name defines the name of the task
  73098. * @param url defines the location of the file to load
  73099. */
  73100. constructor(
  73101. /**
  73102. * Defines the name of the task
  73103. */
  73104. name: string,
  73105. /**
  73106. * Defines the location of the file to load
  73107. */
  73108. url: string);
  73109. /**
  73110. * Execute the current task
  73111. * @param scene defines the scene where you want your assets to be loaded
  73112. * @param onSuccess is a callback called when the task is successfully executed
  73113. * @param onError is a callback called if an error occurs
  73114. */
  73115. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73116. }
  73117. /**
  73118. * Define a task used by AssetsManager to load binary data
  73119. */
  73120. export class BinaryFileAssetTask extends AbstractAssetTask {
  73121. /**
  73122. * Defines the name of the task
  73123. */
  73124. name: string;
  73125. /**
  73126. * Defines the location of the file to load
  73127. */
  73128. url: string;
  73129. /**
  73130. * Gets the lodaded data (as an array buffer)
  73131. */
  73132. data: ArrayBuffer;
  73133. /**
  73134. * Callback called when the task is successful
  73135. */
  73136. onSuccess: (task: BinaryFileAssetTask) => void;
  73137. /**
  73138. * Callback called when the task is successful
  73139. */
  73140. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  73141. /**
  73142. * Creates a new BinaryFileAssetTask object
  73143. * @param name defines the name of the new task
  73144. * @param url defines the location of the file to load
  73145. */
  73146. constructor(
  73147. /**
  73148. * Defines the name of the task
  73149. */
  73150. name: string,
  73151. /**
  73152. * Defines the location of the file to load
  73153. */
  73154. url: string);
  73155. /**
  73156. * Execute the current task
  73157. * @param scene defines the scene where you want your assets to be loaded
  73158. * @param onSuccess is a callback called when the task is successfully executed
  73159. * @param onError is a callback called if an error occurs
  73160. */
  73161. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73162. }
  73163. /**
  73164. * Define a task used by AssetsManager to load images
  73165. */
  73166. export class ImageAssetTask extends AbstractAssetTask {
  73167. /**
  73168. * Defines the name of the task
  73169. */
  73170. name: string;
  73171. /**
  73172. * Defines the location of the image to load
  73173. */
  73174. url: string;
  73175. /**
  73176. * Gets the loaded images
  73177. */
  73178. image: HTMLImageElement;
  73179. /**
  73180. * Callback called when the task is successful
  73181. */
  73182. onSuccess: (task: ImageAssetTask) => void;
  73183. /**
  73184. * Callback called when the task is successful
  73185. */
  73186. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  73187. /**
  73188. * Creates a new ImageAssetTask
  73189. * @param name defines the name of the task
  73190. * @param url defines the location of the image to load
  73191. */
  73192. constructor(
  73193. /**
  73194. * Defines the name of the task
  73195. */
  73196. name: string,
  73197. /**
  73198. * Defines the location of the image to load
  73199. */
  73200. url: string);
  73201. /**
  73202. * Execute the current task
  73203. * @param scene defines the scene where you want your assets to be loaded
  73204. * @param onSuccess is a callback called when the task is successfully executed
  73205. * @param onError is a callback called if an error occurs
  73206. */
  73207. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73208. }
  73209. /**
  73210. * Defines the interface used by texture loading tasks
  73211. */
  73212. export interface ITextureAssetTask<TEX extends BaseTexture> {
  73213. /**
  73214. * Gets the loaded texture
  73215. */
  73216. texture: TEX;
  73217. }
  73218. /**
  73219. * Define a task used by AssetsManager to load 2D textures
  73220. */
  73221. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  73222. /**
  73223. * Defines the name of the task
  73224. */
  73225. name: string;
  73226. /**
  73227. * Defines the location of the file to load
  73228. */
  73229. url: string;
  73230. /**
  73231. * Defines if mipmap should not be generated (default is false)
  73232. */
  73233. noMipmap?: boolean | undefined;
  73234. /**
  73235. * Defines if texture must be inverted on Y axis (default is true)
  73236. */
  73237. invertY: boolean;
  73238. /**
  73239. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73240. */
  73241. samplingMode: number;
  73242. /**
  73243. * Gets the loaded texture
  73244. */
  73245. texture: Texture;
  73246. /**
  73247. * Callback called when the task is successful
  73248. */
  73249. onSuccess: (task: TextureAssetTask) => void;
  73250. /**
  73251. * Callback called when the task is successful
  73252. */
  73253. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  73254. /**
  73255. * Creates a new TextureAssetTask object
  73256. * @param name defines the name of the task
  73257. * @param url defines the location of the file to load
  73258. * @param noMipmap defines if mipmap should not be generated (default is false)
  73259. * @param invertY defines if texture must be inverted on Y axis (default is true)
  73260. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73261. */
  73262. constructor(
  73263. /**
  73264. * Defines the name of the task
  73265. */
  73266. name: string,
  73267. /**
  73268. * Defines the location of the file to load
  73269. */
  73270. url: string,
  73271. /**
  73272. * Defines if mipmap should not be generated (default is false)
  73273. */
  73274. noMipmap?: boolean | undefined,
  73275. /**
  73276. * Defines if texture must be inverted on Y axis (default is true)
  73277. */
  73278. invertY?: boolean,
  73279. /**
  73280. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73281. */
  73282. samplingMode?: number);
  73283. /**
  73284. * Execute the current task
  73285. * @param scene defines the scene where you want your assets to be loaded
  73286. * @param onSuccess is a callback called when the task is successfully executed
  73287. * @param onError is a callback called if an error occurs
  73288. */
  73289. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73290. }
  73291. /**
  73292. * Define a task used by AssetsManager to load cube textures
  73293. */
  73294. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  73295. /**
  73296. * Defines the name of the task
  73297. */
  73298. name: string;
  73299. /**
  73300. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73301. */
  73302. url: string;
  73303. /**
  73304. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73305. */
  73306. extensions?: string[] | undefined;
  73307. /**
  73308. * Defines if mipmaps should not be generated (default is false)
  73309. */
  73310. noMipmap?: boolean | undefined;
  73311. /**
  73312. * Defines the explicit list of files (undefined by default)
  73313. */
  73314. files?: string[] | undefined;
  73315. /**
  73316. * Gets the loaded texture
  73317. */
  73318. texture: CubeTexture;
  73319. /**
  73320. * Callback called when the task is successful
  73321. */
  73322. onSuccess: (task: CubeTextureAssetTask) => void;
  73323. /**
  73324. * Callback called when the task is successful
  73325. */
  73326. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  73327. /**
  73328. * Creates a new CubeTextureAssetTask
  73329. * @param name defines the name of the task
  73330. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73331. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73332. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73333. * @param files defines the explicit list of files (undefined by default)
  73334. */
  73335. constructor(
  73336. /**
  73337. * Defines the name of the task
  73338. */
  73339. name: string,
  73340. /**
  73341. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73342. */
  73343. url: string,
  73344. /**
  73345. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73346. */
  73347. extensions?: string[] | undefined,
  73348. /**
  73349. * Defines if mipmaps should not be generated (default is false)
  73350. */
  73351. noMipmap?: boolean | undefined,
  73352. /**
  73353. * Defines the explicit list of files (undefined by default)
  73354. */
  73355. files?: string[] | undefined);
  73356. /**
  73357. * Execute the current task
  73358. * @param scene defines the scene where you want your assets to be loaded
  73359. * @param onSuccess is a callback called when the task is successfully executed
  73360. * @param onError is a callback called if an error occurs
  73361. */
  73362. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73363. }
  73364. /**
  73365. * Define a task used by AssetsManager to load HDR cube textures
  73366. */
  73367. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  73368. /**
  73369. * Defines the name of the task
  73370. */
  73371. name: string;
  73372. /**
  73373. * Defines the location of the file to load
  73374. */
  73375. url: string;
  73376. /**
  73377. * Defines the desired size (the more it increases the longer the generation will be)
  73378. */
  73379. size: number;
  73380. /**
  73381. * Defines if mipmaps should not be generated (default is false)
  73382. */
  73383. noMipmap: boolean;
  73384. /**
  73385. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73386. */
  73387. generateHarmonics: boolean;
  73388. /**
  73389. * 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)
  73390. */
  73391. gammaSpace: boolean;
  73392. /**
  73393. * Internal Use Only
  73394. */
  73395. reserved: boolean;
  73396. /**
  73397. * Gets the loaded texture
  73398. */
  73399. texture: HDRCubeTexture;
  73400. /**
  73401. * Callback called when the task is successful
  73402. */
  73403. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  73404. /**
  73405. * Callback called when the task is successful
  73406. */
  73407. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  73408. /**
  73409. * Creates a new HDRCubeTextureAssetTask object
  73410. * @param name defines the name of the task
  73411. * @param url defines the location of the file to load
  73412. * @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.
  73413. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73414. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73415. * @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)
  73416. * @param reserved Internal use only
  73417. */
  73418. constructor(
  73419. /**
  73420. * Defines the name of the task
  73421. */
  73422. name: string,
  73423. /**
  73424. * Defines the location of the file to load
  73425. */
  73426. url: string,
  73427. /**
  73428. * Defines the desired size (the more it increases the longer the generation will be)
  73429. */
  73430. size: number,
  73431. /**
  73432. * Defines if mipmaps should not be generated (default is false)
  73433. */
  73434. noMipmap?: boolean,
  73435. /**
  73436. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73437. */
  73438. generateHarmonics?: boolean,
  73439. /**
  73440. * 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)
  73441. */
  73442. gammaSpace?: boolean,
  73443. /**
  73444. * Internal Use Only
  73445. */
  73446. reserved?: boolean);
  73447. /**
  73448. * Execute the current task
  73449. * @param scene defines the scene where you want your assets to be loaded
  73450. * @param onSuccess is a callback called when the task is successfully executed
  73451. * @param onError is a callback called if an error occurs
  73452. */
  73453. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73454. }
  73455. /**
  73456. * Define a task used by AssetsManager to load Equirectangular cube textures
  73457. */
  73458. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  73459. /**
  73460. * Defines the name of the task
  73461. */
  73462. name: string;
  73463. /**
  73464. * Defines the location of the file to load
  73465. */
  73466. url: string;
  73467. /**
  73468. * Defines the desired size (the more it increases the longer the generation will be)
  73469. */
  73470. size: number;
  73471. /**
  73472. * Defines if mipmaps should not be generated (default is false)
  73473. */
  73474. noMipmap: boolean;
  73475. /**
  73476. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73477. * but the standard material would require them in Gamma space) (default is true)
  73478. */
  73479. gammaSpace: boolean;
  73480. /**
  73481. * Gets the loaded texture
  73482. */
  73483. texture: EquiRectangularCubeTexture;
  73484. /**
  73485. * Callback called when the task is successful
  73486. */
  73487. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  73488. /**
  73489. * Callback called when the task is successful
  73490. */
  73491. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  73492. /**
  73493. * Creates a new EquiRectangularCubeTextureAssetTask object
  73494. * @param name defines the name of the task
  73495. * @param url defines the location of the file to load
  73496. * @param size defines the desired size (the more it increases the longer the generation will be)
  73497. * If the size is omitted this implies you are using a preprocessed cubemap.
  73498. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73499. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  73500. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  73501. * (default is true)
  73502. */
  73503. constructor(
  73504. /**
  73505. * Defines the name of the task
  73506. */
  73507. name: string,
  73508. /**
  73509. * Defines the location of the file to load
  73510. */
  73511. url: string,
  73512. /**
  73513. * Defines the desired size (the more it increases the longer the generation will be)
  73514. */
  73515. size: number,
  73516. /**
  73517. * Defines if mipmaps should not be generated (default is false)
  73518. */
  73519. noMipmap?: boolean,
  73520. /**
  73521. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73522. * but the standard material would require them in Gamma space) (default is true)
  73523. */
  73524. gammaSpace?: boolean);
  73525. /**
  73526. * Execute the current task
  73527. * @param scene defines the scene where you want your assets to be loaded
  73528. * @param onSuccess is a callback called when the task is successfully executed
  73529. * @param onError is a callback called if an error occurs
  73530. */
  73531. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73532. }
  73533. /**
  73534. * This class can be used to easily import assets into a scene
  73535. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  73536. */
  73537. export class AssetsManager {
  73538. private _scene;
  73539. private _isLoading;
  73540. protected _tasks: AbstractAssetTask[];
  73541. protected _waitingTasksCount: number;
  73542. protected _totalTasksCount: number;
  73543. /**
  73544. * Callback called when all tasks are processed
  73545. */
  73546. onFinish: (tasks: AbstractAssetTask[]) => void;
  73547. /**
  73548. * Callback called when a task is successful
  73549. */
  73550. onTaskSuccess: (task: AbstractAssetTask) => void;
  73551. /**
  73552. * Callback called when a task had an error
  73553. */
  73554. onTaskError: (task: AbstractAssetTask) => void;
  73555. /**
  73556. * Callback called when a task is done (whatever the result is)
  73557. */
  73558. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  73559. /**
  73560. * Observable called when all tasks are processed
  73561. */
  73562. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  73563. /**
  73564. * Observable called when a task had an error
  73565. */
  73566. onTaskErrorObservable: Observable<AbstractAssetTask>;
  73567. /**
  73568. * Observable called when all tasks were executed
  73569. */
  73570. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  73571. /**
  73572. * Observable called when a task is done (whatever the result is)
  73573. */
  73574. onProgressObservable: Observable<IAssetsProgressEvent>;
  73575. /**
  73576. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  73577. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  73578. */
  73579. useDefaultLoadingScreen: boolean;
  73580. /**
  73581. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  73582. * when all assets have been downloaded.
  73583. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  73584. */
  73585. autoHideLoadingUI: boolean;
  73586. /**
  73587. * Creates a new AssetsManager
  73588. * @param scene defines the scene to work on
  73589. */
  73590. constructor(scene: Scene);
  73591. /**
  73592. * Add a ContainerAssetTask to the list of active tasks
  73593. * @param taskName defines the name of the new task
  73594. * @param meshesNames defines the name of meshes to load
  73595. * @param rootUrl defines the root url to use to locate files
  73596. * @param sceneFilename defines the filename of the scene file
  73597. * @returns a new ContainerAssetTask object
  73598. */
  73599. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  73600. /**
  73601. * Add a MeshAssetTask to the list of active tasks
  73602. * @param taskName defines the name of the new task
  73603. * @param meshesNames defines the name of meshes to load
  73604. * @param rootUrl defines the root url to use to locate files
  73605. * @param sceneFilename defines the filename of the scene file
  73606. * @returns a new MeshAssetTask object
  73607. */
  73608. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  73609. /**
  73610. * Add a TextFileAssetTask to the list of active tasks
  73611. * @param taskName defines the name of the new task
  73612. * @param url defines the url of the file to load
  73613. * @returns a new TextFileAssetTask object
  73614. */
  73615. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  73616. /**
  73617. * Add a BinaryFileAssetTask to the list of active tasks
  73618. * @param taskName defines the name of the new task
  73619. * @param url defines the url of the file to load
  73620. * @returns a new BinaryFileAssetTask object
  73621. */
  73622. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  73623. /**
  73624. * Add a ImageAssetTask to the list of active tasks
  73625. * @param taskName defines the name of the new task
  73626. * @param url defines the url of the file to load
  73627. * @returns a new ImageAssetTask object
  73628. */
  73629. addImageTask(taskName: string, url: string): ImageAssetTask;
  73630. /**
  73631. * Add a TextureAssetTask to the list of active tasks
  73632. * @param taskName defines the name of the new task
  73633. * @param url defines the url of the file to load
  73634. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73635. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  73636. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  73637. * @returns a new TextureAssetTask object
  73638. */
  73639. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  73640. /**
  73641. * Add a CubeTextureAssetTask to the list of active tasks
  73642. * @param taskName defines the name of the new task
  73643. * @param url defines the url of the file to load
  73644. * @param extensions defines the extension to use to load the cube map (can be null)
  73645. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73646. * @param files defines the list of files to load (can be null)
  73647. * @returns a new CubeTextureAssetTask object
  73648. */
  73649. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  73650. /**
  73651. *
  73652. * Add a HDRCubeTextureAssetTask to the list of active tasks
  73653. * @param taskName defines the name of the new task
  73654. * @param url defines the url of the file to load
  73655. * @param size defines the size you want for the cubemap (can be null)
  73656. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73657. * @param generateHarmonics defines if you want to automatically generate (true by default)
  73658. * @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)
  73659. * @param reserved Internal use only
  73660. * @returns a new HDRCubeTextureAssetTask object
  73661. */
  73662. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  73663. /**
  73664. *
  73665. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  73666. * @param taskName defines the name of the new task
  73667. * @param url defines the url of the file to load
  73668. * @param size defines the size you want for the cubemap (can be null)
  73669. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73670. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  73671. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  73672. * @returns a new EquiRectangularCubeTextureAssetTask object
  73673. */
  73674. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  73675. /**
  73676. * Remove a task from the assets manager.
  73677. * @param task the task to remove
  73678. */
  73679. removeTask(task: AbstractAssetTask): void;
  73680. private _decreaseWaitingTasksCount;
  73681. private _runTask;
  73682. /**
  73683. * Reset the AssetsManager and remove all tasks
  73684. * @return the current instance of the AssetsManager
  73685. */
  73686. reset(): AssetsManager;
  73687. /**
  73688. * Start the loading process
  73689. * @return the current instance of the AssetsManager
  73690. */
  73691. load(): AssetsManager;
  73692. /**
  73693. * Start the loading process as an async operation
  73694. * @return a promise returning the list of failed tasks
  73695. */
  73696. loadAsync(): Promise<void>;
  73697. }
  73698. }
  73699. declare module BABYLON {
  73700. /**
  73701. * Wrapper class for promise with external resolve and reject.
  73702. */
  73703. export class Deferred<T> {
  73704. /**
  73705. * The promise associated with this deferred object.
  73706. */
  73707. readonly promise: Promise<T>;
  73708. private _resolve;
  73709. private _reject;
  73710. /**
  73711. * The resolve method of the promise associated with this deferred object.
  73712. */
  73713. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  73714. /**
  73715. * The reject method of the promise associated with this deferred object.
  73716. */
  73717. get reject(): (reason?: any) => void;
  73718. /**
  73719. * Constructor for this deferred object.
  73720. */
  73721. constructor();
  73722. }
  73723. }
  73724. declare module BABYLON {
  73725. /**
  73726. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  73727. */
  73728. export class MeshExploder {
  73729. private _centerMesh;
  73730. private _meshes;
  73731. private _meshesOrigins;
  73732. private _toCenterVectors;
  73733. private _scaledDirection;
  73734. private _newPosition;
  73735. private _centerPosition;
  73736. /**
  73737. * Explodes meshes from a center mesh.
  73738. * @param meshes The meshes to explode.
  73739. * @param centerMesh The mesh to be center of explosion.
  73740. */
  73741. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  73742. private _setCenterMesh;
  73743. /**
  73744. * Get class name
  73745. * @returns "MeshExploder"
  73746. */
  73747. getClassName(): string;
  73748. /**
  73749. * "Exploded meshes"
  73750. * @returns Array of meshes with the centerMesh at index 0.
  73751. */
  73752. getMeshes(): Array<Mesh>;
  73753. /**
  73754. * Explodes meshes giving a specific direction
  73755. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  73756. */
  73757. explode(direction?: number): void;
  73758. }
  73759. }
  73760. declare module BABYLON {
  73761. /**
  73762. * Class used to help managing file picking and drag'n'drop
  73763. */
  73764. export class FilesInput {
  73765. /**
  73766. * List of files ready to be loaded
  73767. */
  73768. static get FilesToLoad(): {
  73769. [key: string]: File;
  73770. };
  73771. /**
  73772. * Callback called when a file is processed
  73773. */
  73774. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  73775. private _engine;
  73776. private _currentScene;
  73777. private _sceneLoadedCallback;
  73778. private _progressCallback;
  73779. private _additionalRenderLoopLogicCallback;
  73780. private _textureLoadingCallback;
  73781. private _startingProcessingFilesCallback;
  73782. private _onReloadCallback;
  73783. private _errorCallback;
  73784. private _elementToMonitor;
  73785. private _sceneFileToLoad;
  73786. private _filesToLoad;
  73787. /**
  73788. * Creates a new FilesInput
  73789. * @param engine defines the rendering engine
  73790. * @param scene defines the hosting scene
  73791. * @param sceneLoadedCallback callback called when scene is loaded
  73792. * @param progressCallback callback called to track progress
  73793. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  73794. * @param textureLoadingCallback callback called when a texture is loading
  73795. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  73796. * @param onReloadCallback callback called when a reload is requested
  73797. * @param errorCallback callback call if an error occurs
  73798. */
  73799. 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>);
  73800. private _dragEnterHandler;
  73801. private _dragOverHandler;
  73802. private _dropHandler;
  73803. /**
  73804. * Calls this function to listen to drag'n'drop events on a specific DOM element
  73805. * @param elementToMonitor defines the DOM element to track
  73806. */
  73807. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  73808. /** Gets the current list of files to load */
  73809. get filesToLoad(): File[];
  73810. /**
  73811. * Release all associated resources
  73812. */
  73813. dispose(): void;
  73814. private renderFunction;
  73815. private drag;
  73816. private drop;
  73817. private _traverseFolder;
  73818. private _processFiles;
  73819. /**
  73820. * Load files from a drop event
  73821. * @param event defines the drop event to use as source
  73822. */
  73823. loadFiles(event: any): void;
  73824. private _processReload;
  73825. /**
  73826. * Reload the current scene from the loaded files
  73827. */
  73828. reload(): void;
  73829. }
  73830. }
  73831. declare module BABYLON {
  73832. /**
  73833. * Defines the root class used to create scene optimization to use with SceneOptimizer
  73834. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73835. */
  73836. export class SceneOptimization {
  73837. /**
  73838. * Defines the priority of this optimization (0 by default which means first in the list)
  73839. */
  73840. priority: number;
  73841. /**
  73842. * Gets a string describing the action executed by the current optimization
  73843. * @returns description string
  73844. */
  73845. getDescription(): string;
  73846. /**
  73847. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73848. * @param scene defines the current scene where to apply this optimization
  73849. * @param optimizer defines the current optimizer
  73850. * @returns true if everything that can be done was applied
  73851. */
  73852. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73853. /**
  73854. * Creates the SceneOptimization object
  73855. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73856. * @param desc defines the description associated with the optimization
  73857. */
  73858. constructor(
  73859. /**
  73860. * Defines the priority of this optimization (0 by default which means first in the list)
  73861. */
  73862. priority?: number);
  73863. }
  73864. /**
  73865. * Defines an optimization used to reduce the size of render target textures
  73866. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73867. */
  73868. export class TextureOptimization extends SceneOptimization {
  73869. /**
  73870. * Defines the priority of this optimization (0 by default which means first in the list)
  73871. */
  73872. priority: number;
  73873. /**
  73874. * 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
  73875. */
  73876. maximumSize: number;
  73877. /**
  73878. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73879. */
  73880. step: number;
  73881. /**
  73882. * Gets a string describing the action executed by the current optimization
  73883. * @returns description string
  73884. */
  73885. getDescription(): string;
  73886. /**
  73887. * Creates the TextureOptimization object
  73888. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73889. * @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
  73890. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73891. */
  73892. constructor(
  73893. /**
  73894. * Defines the priority of this optimization (0 by default which means first in the list)
  73895. */
  73896. priority?: number,
  73897. /**
  73898. * 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
  73899. */
  73900. maximumSize?: number,
  73901. /**
  73902. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73903. */
  73904. step?: number);
  73905. /**
  73906. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73907. * @param scene defines the current scene where to apply this optimization
  73908. * @param optimizer defines the current optimizer
  73909. * @returns true if everything that can be done was applied
  73910. */
  73911. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73912. }
  73913. /**
  73914. * Defines an optimization used to increase or decrease the rendering resolution
  73915. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73916. */
  73917. export class HardwareScalingOptimization extends SceneOptimization {
  73918. /**
  73919. * Defines the priority of this optimization (0 by default which means first in the list)
  73920. */
  73921. priority: number;
  73922. /**
  73923. * Defines the maximum scale to use (2 by default)
  73924. */
  73925. maximumScale: number;
  73926. /**
  73927. * Defines the step to use between two passes (0.5 by default)
  73928. */
  73929. step: number;
  73930. private _currentScale;
  73931. private _directionOffset;
  73932. /**
  73933. * Gets a string describing the action executed by the current optimization
  73934. * @return description string
  73935. */
  73936. getDescription(): string;
  73937. /**
  73938. * Creates the HardwareScalingOptimization object
  73939. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73940. * @param maximumScale defines the maximum scale to use (2 by default)
  73941. * @param step defines the step to use between two passes (0.5 by default)
  73942. */
  73943. constructor(
  73944. /**
  73945. * Defines the priority of this optimization (0 by default which means first in the list)
  73946. */
  73947. priority?: number,
  73948. /**
  73949. * Defines the maximum scale to use (2 by default)
  73950. */
  73951. maximumScale?: number,
  73952. /**
  73953. * Defines the step to use between two passes (0.5 by default)
  73954. */
  73955. step?: number);
  73956. /**
  73957. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73958. * @param scene defines the current scene where to apply this optimization
  73959. * @param optimizer defines the current optimizer
  73960. * @returns true if everything that can be done was applied
  73961. */
  73962. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73963. }
  73964. /**
  73965. * Defines an optimization used to remove shadows
  73966. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73967. */
  73968. export class ShadowsOptimization extends SceneOptimization {
  73969. /**
  73970. * Gets a string describing the action executed by the current optimization
  73971. * @return description string
  73972. */
  73973. getDescription(): string;
  73974. /**
  73975. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73976. * @param scene defines the current scene where to apply this optimization
  73977. * @param optimizer defines the current optimizer
  73978. * @returns true if everything that can be done was applied
  73979. */
  73980. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73981. }
  73982. /**
  73983. * Defines an optimization used to turn post-processes off
  73984. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73985. */
  73986. export class PostProcessesOptimization extends SceneOptimization {
  73987. /**
  73988. * Gets a string describing the action executed by the current optimization
  73989. * @return description string
  73990. */
  73991. getDescription(): string;
  73992. /**
  73993. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73994. * @param scene defines the current scene where to apply this optimization
  73995. * @param optimizer defines the current optimizer
  73996. * @returns true if everything that can be done was applied
  73997. */
  73998. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73999. }
  74000. /**
  74001. * Defines an optimization used to turn lens flares off
  74002. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74003. */
  74004. export class LensFlaresOptimization extends SceneOptimization {
  74005. /**
  74006. * Gets a string describing the action executed by the current optimization
  74007. * @return description string
  74008. */
  74009. getDescription(): string;
  74010. /**
  74011. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74012. * @param scene defines the current scene where to apply this optimization
  74013. * @param optimizer defines the current optimizer
  74014. * @returns true if everything that can be done was applied
  74015. */
  74016. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74017. }
  74018. /**
  74019. * Defines an optimization based on user defined callback.
  74020. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74021. */
  74022. export class CustomOptimization extends SceneOptimization {
  74023. /**
  74024. * Callback called to apply the custom optimization.
  74025. */
  74026. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  74027. /**
  74028. * Callback called to get custom description
  74029. */
  74030. onGetDescription: () => string;
  74031. /**
  74032. * Gets a string describing the action executed by the current optimization
  74033. * @returns description string
  74034. */
  74035. getDescription(): string;
  74036. /**
  74037. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74038. * @param scene defines the current scene where to apply this optimization
  74039. * @param optimizer defines the current optimizer
  74040. * @returns true if everything that can be done was applied
  74041. */
  74042. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74043. }
  74044. /**
  74045. * Defines an optimization used to turn particles off
  74046. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74047. */
  74048. export class ParticlesOptimization extends SceneOptimization {
  74049. /**
  74050. * Gets a string describing the action executed by the current optimization
  74051. * @return description string
  74052. */
  74053. getDescription(): string;
  74054. /**
  74055. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74056. * @param scene defines the current scene where to apply this optimization
  74057. * @param optimizer defines the current optimizer
  74058. * @returns true if everything that can be done was applied
  74059. */
  74060. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74061. }
  74062. /**
  74063. * Defines an optimization used to turn render targets off
  74064. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74065. */
  74066. export class RenderTargetsOptimization extends SceneOptimization {
  74067. /**
  74068. * Gets a string describing the action executed by the current optimization
  74069. * @return description string
  74070. */
  74071. getDescription(): string;
  74072. /**
  74073. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74074. * @param scene defines the current scene where to apply this optimization
  74075. * @param optimizer defines the current optimizer
  74076. * @returns true if everything that can be done was applied
  74077. */
  74078. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74079. }
  74080. /**
  74081. * Defines an optimization used to merge meshes with compatible materials
  74082. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74083. */
  74084. export class MergeMeshesOptimization extends SceneOptimization {
  74085. private static _UpdateSelectionTree;
  74086. /**
  74087. * Gets or sets a boolean which defines if optimization octree has to be updated
  74088. */
  74089. static get UpdateSelectionTree(): boolean;
  74090. /**
  74091. * Gets or sets a boolean which defines if optimization octree has to be updated
  74092. */
  74093. static set UpdateSelectionTree(value: boolean);
  74094. /**
  74095. * Gets a string describing the action executed by the current optimization
  74096. * @return description string
  74097. */
  74098. getDescription(): string;
  74099. private _canBeMerged;
  74100. /**
  74101. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74102. * @param scene defines the current scene where to apply this optimization
  74103. * @param optimizer defines the current optimizer
  74104. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  74105. * @returns true if everything that can be done was applied
  74106. */
  74107. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  74108. }
  74109. /**
  74110. * Defines a list of options used by SceneOptimizer
  74111. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74112. */
  74113. export class SceneOptimizerOptions {
  74114. /**
  74115. * Defines the target frame rate to reach (60 by default)
  74116. */
  74117. targetFrameRate: number;
  74118. /**
  74119. * Defines the interval between two checkes (2000ms by default)
  74120. */
  74121. trackerDuration: number;
  74122. /**
  74123. * Gets the list of optimizations to apply
  74124. */
  74125. optimizations: SceneOptimization[];
  74126. /**
  74127. * Creates a new list of options used by SceneOptimizer
  74128. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  74129. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  74130. */
  74131. constructor(
  74132. /**
  74133. * Defines the target frame rate to reach (60 by default)
  74134. */
  74135. targetFrameRate?: number,
  74136. /**
  74137. * Defines the interval between two checkes (2000ms by default)
  74138. */
  74139. trackerDuration?: number);
  74140. /**
  74141. * Add a new optimization
  74142. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  74143. * @returns the current SceneOptimizerOptions
  74144. */
  74145. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  74146. /**
  74147. * Add a new custom optimization
  74148. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  74149. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  74150. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74151. * @returns the current SceneOptimizerOptions
  74152. */
  74153. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  74154. /**
  74155. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  74156. * @param targetFrameRate defines the target frame rate (60 by default)
  74157. * @returns a SceneOptimizerOptions object
  74158. */
  74159. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74160. /**
  74161. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  74162. * @param targetFrameRate defines the target frame rate (60 by default)
  74163. * @returns a SceneOptimizerOptions object
  74164. */
  74165. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74166. /**
  74167. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  74168. * @param targetFrameRate defines the target frame rate (60 by default)
  74169. * @returns a SceneOptimizerOptions object
  74170. */
  74171. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74172. }
  74173. /**
  74174. * Class used to run optimizations in order to reach a target frame rate
  74175. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74176. */
  74177. export class SceneOptimizer implements IDisposable {
  74178. private _isRunning;
  74179. private _options;
  74180. private _scene;
  74181. private _currentPriorityLevel;
  74182. private _targetFrameRate;
  74183. private _trackerDuration;
  74184. private _currentFrameRate;
  74185. private _sceneDisposeObserver;
  74186. private _improvementMode;
  74187. /**
  74188. * Defines an observable called when the optimizer reaches the target frame rate
  74189. */
  74190. onSuccessObservable: Observable<SceneOptimizer>;
  74191. /**
  74192. * Defines an observable called when the optimizer enables an optimization
  74193. */
  74194. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  74195. /**
  74196. * Defines an observable called when the optimizer is not able to reach the target frame rate
  74197. */
  74198. onFailureObservable: Observable<SceneOptimizer>;
  74199. /**
  74200. * Gets a boolean indicating if the optimizer is in improvement mode
  74201. */
  74202. get isInImprovementMode(): boolean;
  74203. /**
  74204. * Gets the current priority level (0 at start)
  74205. */
  74206. get currentPriorityLevel(): number;
  74207. /**
  74208. * Gets the current frame rate checked by the SceneOptimizer
  74209. */
  74210. get currentFrameRate(): number;
  74211. /**
  74212. * Gets or sets the current target frame rate (60 by default)
  74213. */
  74214. get targetFrameRate(): number;
  74215. /**
  74216. * Gets or sets the current target frame rate (60 by default)
  74217. */
  74218. set targetFrameRate(value: number);
  74219. /**
  74220. * Gets or sets the current interval between two checks (every 2000ms by default)
  74221. */
  74222. get trackerDuration(): number;
  74223. /**
  74224. * Gets or sets the current interval between two checks (every 2000ms by default)
  74225. */
  74226. set trackerDuration(value: number);
  74227. /**
  74228. * Gets the list of active optimizations
  74229. */
  74230. get optimizations(): SceneOptimization[];
  74231. /**
  74232. * Creates a new SceneOptimizer
  74233. * @param scene defines the scene to work on
  74234. * @param options defines the options to use with the SceneOptimizer
  74235. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  74236. * @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)
  74237. */
  74238. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  74239. /**
  74240. * Stops the current optimizer
  74241. */
  74242. stop(): void;
  74243. /**
  74244. * Reset the optimizer to initial step (current priority level = 0)
  74245. */
  74246. reset(): void;
  74247. /**
  74248. * Start the optimizer. By default it will try to reach a specific framerate
  74249. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  74250. */
  74251. start(): void;
  74252. private _checkCurrentState;
  74253. /**
  74254. * Release all resources
  74255. */
  74256. dispose(): void;
  74257. /**
  74258. * Helper function to create a SceneOptimizer with one single line of code
  74259. * @param scene defines the scene to work on
  74260. * @param options defines the options to use with the SceneOptimizer
  74261. * @param onSuccess defines a callback to call on success
  74262. * @param onFailure defines a callback to call on failure
  74263. * @returns the new SceneOptimizer object
  74264. */
  74265. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  74266. }
  74267. }
  74268. declare module BABYLON {
  74269. /**
  74270. * Class used to serialize a scene into a string
  74271. */
  74272. export class SceneSerializer {
  74273. /**
  74274. * Clear cache used by a previous serialization
  74275. */
  74276. static ClearCache(): void;
  74277. /**
  74278. * Serialize a scene into a JSON compatible object
  74279. * @param scene defines the scene to serialize
  74280. * @returns a JSON compatible object
  74281. */
  74282. static Serialize(scene: Scene): any;
  74283. /**
  74284. * Serialize a mesh into a JSON compatible object
  74285. * @param toSerialize defines the mesh to serialize
  74286. * @param withParents defines if parents must be serialized as well
  74287. * @param withChildren defines if children must be serialized as well
  74288. * @returns a JSON compatible object
  74289. */
  74290. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  74291. }
  74292. }
  74293. declare module BABYLON {
  74294. /**
  74295. * Class used to host texture specific utilities
  74296. */
  74297. export class TextureTools {
  74298. /**
  74299. * Uses the GPU to create a copy texture rescaled at a given size
  74300. * @param texture Texture to copy from
  74301. * @param width defines the desired width
  74302. * @param height defines the desired height
  74303. * @param useBilinearMode defines if bilinear mode has to be used
  74304. * @return the generated texture
  74305. */
  74306. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  74307. }
  74308. }
  74309. declare module BABYLON {
  74310. /**
  74311. * This represents the different options available for the video capture.
  74312. */
  74313. export interface VideoRecorderOptions {
  74314. /** Defines the mime type of the video. */
  74315. mimeType: string;
  74316. /** Defines the FPS the video should be recorded at. */
  74317. fps: number;
  74318. /** Defines the chunk size for the recording data. */
  74319. recordChunckSize: number;
  74320. /** The audio tracks to attach to the recording. */
  74321. audioTracks?: MediaStreamTrack[];
  74322. }
  74323. /**
  74324. * This can help with recording videos from BabylonJS.
  74325. * This is based on the available WebRTC functionalities of the browser.
  74326. *
  74327. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  74328. */
  74329. export class VideoRecorder {
  74330. private static readonly _defaultOptions;
  74331. /**
  74332. * Returns whether or not the VideoRecorder is available in your browser.
  74333. * @param engine Defines the Babylon Engine.
  74334. * @returns true if supported otherwise false.
  74335. */
  74336. static IsSupported(engine: Engine): boolean;
  74337. private readonly _options;
  74338. private _canvas;
  74339. private _mediaRecorder;
  74340. private _recordedChunks;
  74341. private _fileName;
  74342. private _resolve;
  74343. private _reject;
  74344. /**
  74345. * True when a recording is already in progress.
  74346. */
  74347. get isRecording(): boolean;
  74348. /**
  74349. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  74350. * @param engine Defines the BabylonJS Engine you wish to record.
  74351. * @param options Defines options that can be used to customize the capture.
  74352. */
  74353. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  74354. /**
  74355. * Stops the current recording before the default capture timeout passed in the startRecording function.
  74356. */
  74357. stopRecording(): void;
  74358. /**
  74359. * Starts recording the canvas for a max duration specified in parameters.
  74360. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  74361. * If null no automatic download will start and you can rely on the promise to get the data back.
  74362. * @param maxDuration Defines the maximum recording time in seconds.
  74363. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  74364. * @return A promise callback at the end of the recording with the video data in Blob.
  74365. */
  74366. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  74367. /**
  74368. * Releases internal resources used during the recording.
  74369. */
  74370. dispose(): void;
  74371. private _handleDataAvailable;
  74372. private _handleError;
  74373. private _handleStop;
  74374. }
  74375. }
  74376. declare module BABYLON {
  74377. /**
  74378. * Class containing a set of static utilities functions for screenshots
  74379. */
  74380. export class ScreenshotTools {
  74381. /**
  74382. * Captures a screenshot of the current rendering
  74383. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74384. * @param engine defines the rendering engine
  74385. * @param camera defines the source camera
  74386. * @param size This parameter can be set to a single number or to an object with the
  74387. * following (optional) properties: precision, width, height. If a single number is passed,
  74388. * it will be used for both width and height. If an object is passed, the screenshot size
  74389. * will be derived from the parameters. The precision property is a multiplier allowing
  74390. * rendering at a higher or lower resolution
  74391. * @param successCallback defines the callback receives a single parameter which contains the
  74392. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74393. * src parameter of an <img> to display it
  74394. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74395. * Check your browser for supported MIME types
  74396. */
  74397. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  74398. /**
  74399. * Captures a screenshot of the current rendering
  74400. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74401. * @param engine defines the rendering engine
  74402. * @param camera defines the source camera
  74403. * @param size This parameter can be set to a single number or to an object with the
  74404. * following (optional) properties: precision, width, height. If a single number is passed,
  74405. * it will be used for both width and height. If an object is passed, the screenshot size
  74406. * will be derived from the parameters. The precision property is a multiplier allowing
  74407. * rendering at a higher or lower resolution
  74408. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74409. * Check your browser for supported MIME types
  74410. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74411. * to the src parameter of an <img> to display it
  74412. */
  74413. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  74414. /**
  74415. * Generates an image screenshot from the specified camera.
  74416. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74417. * @param engine The engine to use for rendering
  74418. * @param camera The camera to use for rendering
  74419. * @param size This parameter can be set to a single number or to an object with the
  74420. * following (optional) properties: precision, width, height. If a single number is passed,
  74421. * it will be used for both width and height. If an object is passed, the screenshot size
  74422. * will be derived from the parameters. The precision property is a multiplier allowing
  74423. * rendering at a higher or lower resolution
  74424. * @param successCallback The callback receives a single parameter which contains the
  74425. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74426. * src parameter of an <img> to display it
  74427. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74428. * Check your browser for supported MIME types
  74429. * @param samples Texture samples (default: 1)
  74430. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74431. * @param fileName A name for for the downloaded file.
  74432. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74433. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  74434. */
  74435. 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;
  74436. /**
  74437. * Generates an image screenshot from the specified camera.
  74438. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74439. * @param engine The engine to use for rendering
  74440. * @param camera The camera to use for rendering
  74441. * @param size This parameter can be set to a single number or to an object with the
  74442. * following (optional) properties: precision, width, height. If a single number is passed,
  74443. * it will be used for both width and height. If an object is passed, the screenshot size
  74444. * will be derived from the parameters. The precision property is a multiplier allowing
  74445. * rendering at a higher or lower resolution
  74446. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74447. * Check your browser for supported MIME types
  74448. * @param samples Texture samples (default: 1)
  74449. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74450. * @param fileName A name for for the downloaded file.
  74451. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74452. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74453. * to the src parameter of an <img> to display it
  74454. */
  74455. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  74456. /**
  74457. * Gets height and width for screenshot size
  74458. * @private
  74459. */
  74460. private static _getScreenshotSize;
  74461. }
  74462. }
  74463. declare module BABYLON {
  74464. /**
  74465. * Interface for a data buffer
  74466. */
  74467. export interface IDataBuffer {
  74468. /**
  74469. * Reads bytes from the data buffer.
  74470. * @param byteOffset The byte offset to read
  74471. * @param byteLength The byte length to read
  74472. * @returns A promise that resolves when the bytes are read
  74473. */
  74474. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  74475. /**
  74476. * The byte length of the buffer.
  74477. */
  74478. readonly byteLength: number;
  74479. }
  74480. /**
  74481. * Utility class for reading from a data buffer
  74482. */
  74483. export class DataReader {
  74484. /**
  74485. * The data buffer associated with this data reader.
  74486. */
  74487. readonly buffer: IDataBuffer;
  74488. /**
  74489. * The current byte offset from the beginning of the data buffer.
  74490. */
  74491. byteOffset: number;
  74492. private _dataView;
  74493. private _dataByteOffset;
  74494. /**
  74495. * Constructor
  74496. * @param buffer The buffer to read
  74497. */
  74498. constructor(buffer: IDataBuffer);
  74499. /**
  74500. * Loads the given byte length.
  74501. * @param byteLength The byte length to load
  74502. * @returns A promise that resolves when the load is complete
  74503. */
  74504. loadAsync(byteLength: number): Promise<void>;
  74505. /**
  74506. * Read a unsigned 32-bit integer from the currently loaded data range.
  74507. * @returns The 32-bit integer read
  74508. */
  74509. readUint32(): number;
  74510. /**
  74511. * Read a byte array from the currently loaded data range.
  74512. * @param byteLength The byte length to read
  74513. * @returns The byte array read
  74514. */
  74515. readUint8Array(byteLength: number): Uint8Array;
  74516. /**
  74517. * Read a string from the currently loaded data range.
  74518. * @param byteLength The byte length to read
  74519. * @returns The string read
  74520. */
  74521. readString(byteLength: number): string;
  74522. /**
  74523. * Skips the given byte length the currently loaded data range.
  74524. * @param byteLength The byte length to skip
  74525. */
  74526. skipBytes(byteLength: number): void;
  74527. }
  74528. }
  74529. declare module BABYLON {
  74530. /**
  74531. * Class for storing data to local storage if available or in-memory storage otherwise
  74532. */
  74533. export class DataStorage {
  74534. private static _Storage;
  74535. private static _GetStorage;
  74536. /**
  74537. * Reads a string from the data storage
  74538. * @param key The key to read
  74539. * @param defaultValue The value if the key doesn't exist
  74540. * @returns The string value
  74541. */
  74542. static ReadString(key: string, defaultValue: string): string;
  74543. /**
  74544. * Writes a string to the data storage
  74545. * @param key The key to write
  74546. * @param value The value to write
  74547. */
  74548. static WriteString(key: string, value: string): void;
  74549. /**
  74550. * Reads a boolean from the data storage
  74551. * @param key The key to read
  74552. * @param defaultValue The value if the key doesn't exist
  74553. * @returns The boolean value
  74554. */
  74555. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  74556. /**
  74557. * Writes a boolean to the data storage
  74558. * @param key The key to write
  74559. * @param value The value to write
  74560. */
  74561. static WriteBoolean(key: string, value: boolean): void;
  74562. /**
  74563. * Reads a number from the data storage
  74564. * @param key The key to read
  74565. * @param defaultValue The value if the key doesn't exist
  74566. * @returns The number value
  74567. */
  74568. static ReadNumber(key: string, defaultValue: number): number;
  74569. /**
  74570. * Writes a number to the data storage
  74571. * @param key The key to write
  74572. * @param value The value to write
  74573. */
  74574. static WriteNumber(key: string, value: number): void;
  74575. }
  74576. }
  74577. declare module BABYLON {
  74578. /**
  74579. * Class used to record delta files between 2 scene states
  74580. */
  74581. export class SceneRecorder {
  74582. private _trackedScene;
  74583. private _savedJSON;
  74584. /**
  74585. * Track a given scene. This means the current scene state will be considered the original state
  74586. * @param scene defines the scene to track
  74587. */
  74588. track(scene: Scene): void;
  74589. /**
  74590. * Get the delta between current state and original state
  74591. * @returns a string containing the delta
  74592. */
  74593. getDelta(): any;
  74594. private _compareArray;
  74595. private _compareObjects;
  74596. private _compareCollections;
  74597. private static GetShadowGeneratorById;
  74598. /**
  74599. * Apply a given delta to a given scene
  74600. * @param deltaJSON defines the JSON containing the delta
  74601. * @param scene defines the scene to apply the delta to
  74602. */
  74603. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  74604. private static _ApplyPropertiesToEntity;
  74605. private static _ApplyDeltaForEntity;
  74606. }
  74607. }
  74608. declare module BABYLON {
  74609. /**
  74610. * A 3D trajectory consisting of an order list of vectors describing a
  74611. * path of motion through 3D space.
  74612. */
  74613. export class Trajectory {
  74614. private _points;
  74615. private readonly _segmentLength;
  74616. /**
  74617. * Serialize to JSON.
  74618. * @returns serialized JSON string
  74619. */
  74620. serialize(): string;
  74621. /**
  74622. * Deserialize from JSON.
  74623. * @param json serialized JSON string
  74624. * @returns deserialized Trajectory
  74625. */
  74626. static Deserialize(json: string): Trajectory;
  74627. /**
  74628. * Create a new empty Trajectory.
  74629. * @param segmentLength radius of discretization for Trajectory points
  74630. */
  74631. constructor(segmentLength?: number);
  74632. /**
  74633. * Get the length of the Trajectory.
  74634. * @returns length of the Trajectory
  74635. */
  74636. getLength(): number;
  74637. /**
  74638. * Append a new point to the Trajectory.
  74639. * NOTE: This implementation has many allocations.
  74640. * @param point point to append to the Trajectory
  74641. */
  74642. add(point: DeepImmutable<Vector3>): void;
  74643. /**
  74644. * Create a new Trajectory with a segment length chosen to make it
  74645. * probable that the new Trajectory will have a specified number of
  74646. * segments. This operation is imprecise.
  74647. * @param targetResolution number of segments desired
  74648. * @returns new Trajectory with approximately the requested number of segments
  74649. */
  74650. resampleAtTargetResolution(targetResolution: number): Trajectory;
  74651. /**
  74652. * Convert Trajectory segments into tokenized representation. This
  74653. * representation is an array of numbers where each nth number is the
  74654. * index of the token which is most similar to the nth segment of the
  74655. * Trajectory.
  74656. * @param tokens list of vectors which serve as discrete tokens
  74657. * @returns list of indices of most similar token per segment
  74658. */
  74659. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  74660. private static _forwardDir;
  74661. private static _inverseFromVec;
  74662. private static _upDir;
  74663. private static _fromToVec;
  74664. private static _lookMatrix;
  74665. /**
  74666. * Transform the rotation (i.e., direction) of a segment to isolate
  74667. * the relative transformation represented by the segment. This operation
  74668. * may or may not succeed due to singularities in the equations that define
  74669. * motion relativity in this context.
  74670. * @param priorVec the origin of the prior segment
  74671. * @param fromVec the origin of the current segment
  74672. * @param toVec the destination of the current segment
  74673. * @param result reference to output variable
  74674. * @returns whether or not transformation was successful
  74675. */
  74676. private static _transformSegmentDirToRef;
  74677. private static _bestMatch;
  74678. private static _score;
  74679. private static _bestScore;
  74680. /**
  74681. * Determine which token vector is most similar to the
  74682. * segment vector.
  74683. * @param segment segment vector
  74684. * @param tokens token vector list
  74685. * @returns index of the most similar token to the segment
  74686. */
  74687. private static _tokenizeSegment;
  74688. }
  74689. /**
  74690. * Class representing a set of known, named trajectories to which Trajectories can be
  74691. * added and using which Trajectories can be recognized.
  74692. */
  74693. export class TrajectoryClassifier {
  74694. private _maximumAllowableMatchCost;
  74695. private _vector3Alphabet;
  74696. private _levenshteinAlphabet;
  74697. private _nameToDescribedTrajectory;
  74698. /**
  74699. * Serialize to JSON.
  74700. * @returns JSON serialization
  74701. */
  74702. serialize(): string;
  74703. /**
  74704. * Deserialize from JSON.
  74705. * @param json JSON serialization
  74706. * @returns deserialized TrajectorySet
  74707. */
  74708. static Deserialize(json: string): TrajectoryClassifier;
  74709. /**
  74710. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  74711. * VERY naive, need to be generating these things from known
  74712. * sets. Better version later, probably eliminating this one.
  74713. * @returns auto-generated TrajectorySet
  74714. */
  74715. static Generate(): TrajectoryClassifier;
  74716. private constructor();
  74717. /**
  74718. * Add a new Trajectory to the set with a given name.
  74719. * @param trajectory new Trajectory to be added
  74720. * @param classification name to which to add the Trajectory
  74721. */
  74722. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  74723. /**
  74724. * Remove a known named trajectory and all Trajectories associated with it.
  74725. * @param classification name to remove
  74726. * @returns whether anything was removed
  74727. */
  74728. deleteClassification(classification: string): boolean;
  74729. /**
  74730. * Attempt to recognize a Trajectory from among all the classifications
  74731. * already known to the classifier.
  74732. * @param trajectory Trajectory to be recognized
  74733. * @returns classification of Trajectory if recognized, null otherwise
  74734. */
  74735. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  74736. }
  74737. }
  74738. declare module BABYLON {
  74739. /**
  74740. * An interface for all Hit test features
  74741. */
  74742. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  74743. /**
  74744. * Triggered when new babylon (transformed) hit test results are available
  74745. */
  74746. onHitTestResultObservable: Observable<T[]>;
  74747. }
  74748. /**
  74749. * Options used for hit testing
  74750. */
  74751. export interface IWebXRLegacyHitTestOptions {
  74752. /**
  74753. * Only test when user interacted with the scene. Default - hit test every frame
  74754. */
  74755. testOnPointerDownOnly?: boolean;
  74756. /**
  74757. * The node to use to transform the local results to world coordinates
  74758. */
  74759. worldParentNode?: TransformNode;
  74760. }
  74761. /**
  74762. * Interface defining the babylon result of raycasting/hit-test
  74763. */
  74764. export interface IWebXRLegacyHitResult {
  74765. /**
  74766. * Transformation matrix that can be applied to a node that will put it in the hit point location
  74767. */
  74768. transformationMatrix: Matrix;
  74769. /**
  74770. * The native hit test result
  74771. */
  74772. xrHitResult: XRHitResult | XRHitTestResult;
  74773. }
  74774. /**
  74775. * The currently-working hit-test module.
  74776. * Hit test (or Ray-casting) is used to interact with the real world.
  74777. * For further information read here - https://github.com/immersive-web/hit-test
  74778. */
  74779. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  74780. /**
  74781. * options to use when constructing this feature
  74782. */
  74783. readonly options: IWebXRLegacyHitTestOptions;
  74784. private _direction;
  74785. private _mat;
  74786. private _onSelectEnabled;
  74787. private _origin;
  74788. /**
  74789. * The module's name
  74790. */
  74791. static readonly Name: string;
  74792. /**
  74793. * The (Babylon) version of this module.
  74794. * This is an integer representing the implementation version.
  74795. * This number does not correspond to the WebXR specs version
  74796. */
  74797. static readonly Version: number;
  74798. /**
  74799. * Populated with the last native XR Hit Results
  74800. */
  74801. lastNativeXRHitResults: XRHitResult[];
  74802. /**
  74803. * Triggered when new babylon (transformed) hit test results are available
  74804. */
  74805. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  74806. /**
  74807. * Creates a new instance of the (legacy version) hit test feature
  74808. * @param _xrSessionManager an instance of WebXRSessionManager
  74809. * @param options options to use when constructing this feature
  74810. */
  74811. constructor(_xrSessionManager: WebXRSessionManager,
  74812. /**
  74813. * options to use when constructing this feature
  74814. */
  74815. options?: IWebXRLegacyHitTestOptions);
  74816. /**
  74817. * execute a hit test with an XR Ray
  74818. *
  74819. * @param xrSession a native xrSession that will execute this hit test
  74820. * @param xrRay the ray (position and direction) to use for ray-casting
  74821. * @param referenceSpace native XR reference space to use for the hit-test
  74822. * @param filter filter function that will filter the results
  74823. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  74824. */
  74825. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  74826. /**
  74827. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  74828. * @param event the (select) event to use to select with
  74829. * @param referenceSpace the reference space to use for this hit test
  74830. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  74831. */
  74832. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  74833. /**
  74834. * attach this feature
  74835. * Will usually be called by the features manager
  74836. *
  74837. * @returns true if successful.
  74838. */
  74839. attach(): boolean;
  74840. /**
  74841. * detach this feature.
  74842. * Will usually be called by the features manager
  74843. *
  74844. * @returns true if successful.
  74845. */
  74846. detach(): boolean;
  74847. /**
  74848. * Dispose this feature and all of the resources attached
  74849. */
  74850. dispose(): void;
  74851. protected _onXRFrame(frame: XRFrame): void;
  74852. private _onHitTestResults;
  74853. private _onSelect;
  74854. }
  74855. }
  74856. declare module BABYLON {
  74857. /**
  74858. * Options used for hit testing (version 2)
  74859. */
  74860. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  74861. /**
  74862. * Do not create a permanent hit test. Will usually be used when only
  74863. * transient inputs are needed.
  74864. */
  74865. disablePermanentHitTest?: boolean;
  74866. /**
  74867. * Enable transient (for example touch-based) hit test inspections
  74868. */
  74869. enableTransientHitTest?: boolean;
  74870. /**
  74871. * Offset ray for the permanent hit test
  74872. */
  74873. offsetRay?: Vector3;
  74874. /**
  74875. * Offset ray for the transient hit test
  74876. */
  74877. transientOffsetRay?: Vector3;
  74878. /**
  74879. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  74880. */
  74881. useReferenceSpace?: boolean;
  74882. /**
  74883. * Override the default entity type(s) of the hit-test result
  74884. */
  74885. entityTypes?: XRHitTestTrackableType[];
  74886. }
  74887. /**
  74888. * Interface defining the babylon result of hit-test
  74889. */
  74890. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  74891. /**
  74892. * The input source that generated this hit test (if transient)
  74893. */
  74894. inputSource?: XRInputSource;
  74895. /**
  74896. * Is this a transient hit test
  74897. */
  74898. isTransient?: boolean;
  74899. /**
  74900. * Position of the hit test result
  74901. */
  74902. position: Vector3;
  74903. /**
  74904. * Rotation of the hit test result
  74905. */
  74906. rotationQuaternion: Quaternion;
  74907. /**
  74908. * The native hit test result
  74909. */
  74910. xrHitResult: XRHitTestResult;
  74911. }
  74912. /**
  74913. * The currently-working hit-test module.
  74914. * Hit test (or Ray-casting) is used to interact with the real world.
  74915. * For further information read here - https://github.com/immersive-web/hit-test
  74916. *
  74917. * Tested on chrome (mobile) 80.
  74918. */
  74919. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  74920. /**
  74921. * options to use when constructing this feature
  74922. */
  74923. readonly options: IWebXRHitTestOptions;
  74924. private _tmpMat;
  74925. private _tmpPos;
  74926. private _tmpQuat;
  74927. private _transientXrHitTestSource;
  74928. private _xrHitTestSource;
  74929. private initHitTestSource;
  74930. /**
  74931. * The module's name
  74932. */
  74933. static readonly Name: string;
  74934. /**
  74935. * The (Babylon) version of this module.
  74936. * This is an integer representing the implementation version.
  74937. * This number does not correspond to the WebXR specs version
  74938. */
  74939. static readonly Version: number;
  74940. /**
  74941. * When set to true, each hit test will have its own position/rotation objects
  74942. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  74943. * the developers will clone them or copy them as they see fit.
  74944. */
  74945. autoCloneTransformation: boolean;
  74946. /**
  74947. * Triggered when new babylon (transformed) hit test results are available
  74948. * Note - this will be called when results come back from the device. It can be an empty array!!
  74949. */
  74950. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  74951. /**
  74952. * Use this to temporarily pause hit test checks.
  74953. */
  74954. paused: boolean;
  74955. /**
  74956. * Creates a new instance of the hit test feature
  74957. * @param _xrSessionManager an instance of WebXRSessionManager
  74958. * @param options options to use when constructing this feature
  74959. */
  74960. constructor(_xrSessionManager: WebXRSessionManager,
  74961. /**
  74962. * options to use when constructing this feature
  74963. */
  74964. options?: IWebXRHitTestOptions);
  74965. /**
  74966. * attach this feature
  74967. * Will usually be called by the features manager
  74968. *
  74969. * @returns true if successful.
  74970. */
  74971. attach(): boolean;
  74972. /**
  74973. * detach this feature.
  74974. * Will usually be called by the features manager
  74975. *
  74976. * @returns true if successful.
  74977. */
  74978. detach(): boolean;
  74979. /**
  74980. * Dispose this feature and all of the resources attached
  74981. */
  74982. dispose(): void;
  74983. protected _onXRFrame(frame: XRFrame): void;
  74984. private _processWebXRHitTestResult;
  74985. }
  74986. }
  74987. declare module BABYLON {
  74988. /**
  74989. * Configuration options of the anchor system
  74990. */
  74991. export interface IWebXRAnchorSystemOptions {
  74992. /**
  74993. * a node that will be used to convert local to world coordinates
  74994. */
  74995. worldParentNode?: TransformNode;
  74996. /**
  74997. * If set to true a reference of the created anchors will be kept until the next session starts
  74998. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  74999. */
  75000. doNotRemoveAnchorsOnSessionEnded?: boolean;
  75001. }
  75002. /**
  75003. * A babylon container for an XR Anchor
  75004. */
  75005. export interface IWebXRAnchor {
  75006. /**
  75007. * A babylon-assigned ID for this anchor
  75008. */
  75009. id: number;
  75010. /**
  75011. * Transformation matrix to apply to an object attached to this anchor
  75012. */
  75013. transformationMatrix: Matrix;
  75014. /**
  75015. * The native anchor object
  75016. */
  75017. xrAnchor: XRAnchor;
  75018. /**
  75019. * if defined, this object will be constantly updated by the anchor's position and rotation
  75020. */
  75021. attachedNode?: TransformNode;
  75022. }
  75023. /**
  75024. * An implementation of the anchor system for WebXR.
  75025. * For further information see https://github.com/immersive-web/anchors/
  75026. */
  75027. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  75028. private _options;
  75029. private _lastFrameDetected;
  75030. private _trackedAnchors;
  75031. private _referenceSpaceForFrameAnchors;
  75032. private _futureAnchors;
  75033. /**
  75034. * The module's name
  75035. */
  75036. static readonly Name: string;
  75037. /**
  75038. * The (Babylon) version of this module.
  75039. * This is an integer representing the implementation version.
  75040. * This number does not correspond to the WebXR specs version
  75041. */
  75042. static readonly Version: number;
  75043. /**
  75044. * Observers registered here will be executed when a new anchor was added to the session
  75045. */
  75046. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  75047. /**
  75048. * Observers registered here will be executed when an anchor was removed from the session
  75049. */
  75050. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  75051. /**
  75052. * Observers registered here will be executed when an existing anchor updates
  75053. * This can execute N times every frame
  75054. */
  75055. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  75056. /**
  75057. * Set the reference space to use for anchor creation, when not using a hit test.
  75058. * Will default to the session's reference space if not defined
  75059. */
  75060. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  75061. /**
  75062. * constructs a new anchor system
  75063. * @param _xrSessionManager an instance of WebXRSessionManager
  75064. * @param _options configuration object for this feature
  75065. */
  75066. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  75067. private _tmpVector;
  75068. private _tmpQuaternion;
  75069. private _populateTmpTransformation;
  75070. /**
  75071. * Create a new anchor point using a hit test result at a specific point in the scene
  75072. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  75073. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  75074. *
  75075. * @param hitTestResult The hit test result to use for this anchor creation
  75076. * @param position an optional position offset for this anchor
  75077. * @param rotationQuaternion an optional rotation offset for this anchor
  75078. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  75079. */
  75080. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  75081. /**
  75082. * Add a new anchor at a specific position and rotation
  75083. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  75084. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  75085. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  75086. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  75087. *
  75088. * @param position the position in which to add an anchor
  75089. * @param rotationQuaternion an optional rotation for the anchor transformation
  75090. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  75091. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  75092. */
  75093. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  75094. /**
  75095. * detach this feature.
  75096. * Will usually be called by the features manager
  75097. *
  75098. * @returns true if successful.
  75099. */
  75100. detach(): boolean;
  75101. /**
  75102. * Dispose this feature and all of the resources attached
  75103. */
  75104. dispose(): void;
  75105. protected _onXRFrame(frame: XRFrame): void;
  75106. /**
  75107. * avoiding using Array.find for global support.
  75108. * @param xrAnchor the plane to find in the array
  75109. */
  75110. private _findIndexInAnchorArray;
  75111. private _updateAnchorWithXRFrame;
  75112. private _createAnchorAtTransformation;
  75113. }
  75114. }
  75115. declare module BABYLON {
  75116. /**
  75117. * Options used in the plane detector module
  75118. */
  75119. export interface IWebXRPlaneDetectorOptions {
  75120. /**
  75121. * The node to use to transform the local results to world coordinates
  75122. */
  75123. worldParentNode?: TransformNode;
  75124. /**
  75125. * If set to true a reference of the created planes will be kept until the next session starts
  75126. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  75127. */
  75128. doNotRemovePlanesOnSessionEnded?: boolean;
  75129. }
  75130. /**
  75131. * A babylon interface for a WebXR plane.
  75132. * A Plane is actually a polygon, built from N points in space
  75133. *
  75134. * Supported in chrome 79, not supported in canary 81 ATM
  75135. */
  75136. export interface IWebXRPlane {
  75137. /**
  75138. * a babylon-assigned ID for this polygon
  75139. */
  75140. id: number;
  75141. /**
  75142. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  75143. */
  75144. polygonDefinition: Array<Vector3>;
  75145. /**
  75146. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  75147. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  75148. */
  75149. transformationMatrix: Matrix;
  75150. /**
  75151. * the native xr-plane object
  75152. */
  75153. xrPlane: XRPlane;
  75154. }
  75155. /**
  75156. * The plane detector is used to detect planes in the real world when in AR
  75157. * For more information see https://github.com/immersive-web/real-world-geometry/
  75158. */
  75159. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  75160. private _options;
  75161. private _detectedPlanes;
  75162. private _enabled;
  75163. private _lastFrameDetected;
  75164. /**
  75165. * The module's name
  75166. */
  75167. static readonly Name: string;
  75168. /**
  75169. * The (Babylon) version of this module.
  75170. * This is an integer representing the implementation version.
  75171. * This number does not correspond to the WebXR specs version
  75172. */
  75173. static readonly Version: number;
  75174. /**
  75175. * Observers registered here will be executed when a new plane was added to the session
  75176. */
  75177. onPlaneAddedObservable: Observable<IWebXRPlane>;
  75178. /**
  75179. * Observers registered here will be executed when a plane is no longer detected in the session
  75180. */
  75181. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  75182. /**
  75183. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  75184. * This can execute N times every frame
  75185. */
  75186. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  75187. /**
  75188. * construct a new Plane Detector
  75189. * @param _xrSessionManager an instance of xr Session manager
  75190. * @param _options configuration to use when constructing this feature
  75191. */
  75192. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  75193. /**
  75194. * detach this feature.
  75195. * Will usually be called by the features manager
  75196. *
  75197. * @returns true if successful.
  75198. */
  75199. detach(): boolean;
  75200. /**
  75201. * Dispose this feature and all of the resources attached
  75202. */
  75203. dispose(): void;
  75204. protected _onXRFrame(frame: XRFrame): void;
  75205. private _init;
  75206. private _updatePlaneWithXRPlane;
  75207. /**
  75208. * avoiding using Array.find for global support.
  75209. * @param xrPlane the plane to find in the array
  75210. */
  75211. private findIndexInPlaneArray;
  75212. }
  75213. }
  75214. declare module BABYLON {
  75215. /**
  75216. * Options interface for the background remover plugin
  75217. */
  75218. export interface IWebXRBackgroundRemoverOptions {
  75219. /**
  75220. * Further background meshes to disable when entering AR
  75221. */
  75222. backgroundMeshes?: AbstractMesh[];
  75223. /**
  75224. * flags to configure the removal of the environment helper.
  75225. * If not set, the entire background will be removed. If set, flags should be set as well.
  75226. */
  75227. environmentHelperRemovalFlags?: {
  75228. /**
  75229. * Should the skybox be removed (default false)
  75230. */
  75231. skyBox?: boolean;
  75232. /**
  75233. * Should the ground be removed (default false)
  75234. */
  75235. ground?: boolean;
  75236. };
  75237. /**
  75238. * don't disable the environment helper
  75239. */
  75240. ignoreEnvironmentHelper?: boolean;
  75241. }
  75242. /**
  75243. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  75244. */
  75245. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  75246. /**
  75247. * read-only options to be used in this module
  75248. */
  75249. readonly options: IWebXRBackgroundRemoverOptions;
  75250. /**
  75251. * The module's name
  75252. */
  75253. static readonly Name: string;
  75254. /**
  75255. * The (Babylon) version of this module.
  75256. * This is an integer representing the implementation version.
  75257. * This number does not correspond to the WebXR specs version
  75258. */
  75259. static readonly Version: number;
  75260. /**
  75261. * registered observers will be triggered when the background state changes
  75262. */
  75263. onBackgroundStateChangedObservable: Observable<boolean>;
  75264. /**
  75265. * constructs a new background remover module
  75266. * @param _xrSessionManager the session manager for this module
  75267. * @param options read-only options to be used in this module
  75268. */
  75269. constructor(_xrSessionManager: WebXRSessionManager,
  75270. /**
  75271. * read-only options to be used in this module
  75272. */
  75273. options?: IWebXRBackgroundRemoverOptions);
  75274. /**
  75275. * attach this feature
  75276. * Will usually be called by the features manager
  75277. *
  75278. * @returns true if successful.
  75279. */
  75280. attach(): boolean;
  75281. /**
  75282. * detach this feature.
  75283. * Will usually be called by the features manager
  75284. *
  75285. * @returns true if successful.
  75286. */
  75287. detach(): boolean;
  75288. /**
  75289. * Dispose this feature and all of the resources attached
  75290. */
  75291. dispose(): void;
  75292. protected _onXRFrame(_xrFrame: XRFrame): void;
  75293. private _setBackgroundState;
  75294. }
  75295. }
  75296. declare module BABYLON {
  75297. /**
  75298. * Options for the controller physics feature
  75299. */
  75300. export class IWebXRControllerPhysicsOptions {
  75301. /**
  75302. * Should the headset get its own impostor
  75303. */
  75304. enableHeadsetImpostor?: boolean;
  75305. /**
  75306. * Optional parameters for the headset impostor
  75307. */
  75308. headsetImpostorParams?: {
  75309. /**
  75310. * The type of impostor to create. Default is sphere
  75311. */
  75312. impostorType: number;
  75313. /**
  75314. * the size of the impostor. Defaults to 10cm
  75315. */
  75316. impostorSize?: number | {
  75317. width: number;
  75318. height: number;
  75319. depth: number;
  75320. };
  75321. /**
  75322. * Friction definitions
  75323. */
  75324. friction?: number;
  75325. /**
  75326. * Restitution
  75327. */
  75328. restitution?: number;
  75329. };
  75330. /**
  75331. * The physics properties of the future impostors
  75332. */
  75333. physicsProperties?: {
  75334. /**
  75335. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  75336. * Note that this requires a physics engine that supports mesh impostors!
  75337. */
  75338. useControllerMesh?: boolean;
  75339. /**
  75340. * The type of impostor to create. Default is sphere
  75341. */
  75342. impostorType?: number;
  75343. /**
  75344. * the size of the impostor. Defaults to 10cm
  75345. */
  75346. impostorSize?: number | {
  75347. width: number;
  75348. height: number;
  75349. depth: number;
  75350. };
  75351. /**
  75352. * Friction definitions
  75353. */
  75354. friction?: number;
  75355. /**
  75356. * Restitution
  75357. */
  75358. restitution?: number;
  75359. };
  75360. /**
  75361. * the xr input to use with this pointer selection
  75362. */
  75363. xrInput: WebXRInput;
  75364. }
  75365. /**
  75366. * Add physics impostor to your webxr controllers,
  75367. * including naive calculation of their linear and angular velocity
  75368. */
  75369. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  75370. private readonly _options;
  75371. private _attachController;
  75372. private _controllers;
  75373. private _debugMode;
  75374. private _delta;
  75375. private _headsetImpostor?;
  75376. private _headsetMesh?;
  75377. private _lastTimestamp;
  75378. private _tmpQuaternion;
  75379. private _tmpVector;
  75380. /**
  75381. * The module's name
  75382. */
  75383. static readonly Name: string;
  75384. /**
  75385. * The (Babylon) version of this module.
  75386. * This is an integer representing the implementation version.
  75387. * This number does not correspond to the webxr specs version
  75388. */
  75389. static readonly Version: number;
  75390. /**
  75391. * Construct a new Controller Physics Feature
  75392. * @param _xrSessionManager the corresponding xr session manager
  75393. * @param _options options to create this feature with
  75394. */
  75395. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  75396. /**
  75397. * @hidden
  75398. * enable debugging - will show console outputs and the impostor mesh
  75399. */
  75400. _enablePhysicsDebug(): void;
  75401. /**
  75402. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  75403. * @param xrController the controller to add
  75404. */
  75405. addController(xrController: WebXRInputSource): void;
  75406. /**
  75407. * attach this feature
  75408. * Will usually be called by the features manager
  75409. *
  75410. * @returns true if successful.
  75411. */
  75412. attach(): boolean;
  75413. /**
  75414. * detach this feature.
  75415. * Will usually be called by the features manager
  75416. *
  75417. * @returns true if successful.
  75418. */
  75419. detach(): boolean;
  75420. /**
  75421. * Get the headset impostor, if enabled
  75422. * @returns the impostor
  75423. */
  75424. getHeadsetImpostor(): PhysicsImpostor | undefined;
  75425. /**
  75426. * Get the physics impostor of a specific controller.
  75427. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  75428. * @param controller the controller or the controller id of which to get the impostor
  75429. * @returns the impostor or null
  75430. */
  75431. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  75432. /**
  75433. * Update the physics properties provided in the constructor
  75434. * @param newProperties the new properties object
  75435. */
  75436. setPhysicsProperties(newProperties: {
  75437. impostorType?: number;
  75438. impostorSize?: number | {
  75439. width: number;
  75440. height: number;
  75441. depth: number;
  75442. };
  75443. friction?: number;
  75444. restitution?: number;
  75445. }): void;
  75446. protected _onXRFrame(_xrFrame: any): void;
  75447. private _detachController;
  75448. }
  75449. }
  75450. declare module BABYLON {
  75451. /**
  75452. * A babylon interface for a "WebXR" feature point.
  75453. * Represents the position and confidence value of a given feature point.
  75454. */
  75455. export interface IWebXRFeaturePoint {
  75456. /**
  75457. * Represents the position of the feature point in world space.
  75458. */
  75459. position: Vector3;
  75460. /**
  75461. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  75462. */
  75463. confidenceValue: number;
  75464. }
  75465. /**
  75466. * The feature point system is used to detect feature points from real world geometry.
  75467. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  75468. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  75469. */
  75470. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  75471. private _enabled;
  75472. private _featurePointCloud;
  75473. /**
  75474. * The module's name
  75475. */
  75476. static readonly Name: string;
  75477. /**
  75478. * The (Babylon) version of this module.
  75479. * This is an integer representing the implementation version.
  75480. * This number does not correspond to the WebXR specs version
  75481. */
  75482. static readonly Version: number;
  75483. /**
  75484. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  75485. * Will notify the observers about which feature points have been added.
  75486. */
  75487. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  75488. /**
  75489. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  75490. * Will notify the observers about which feature points have been updated.
  75491. */
  75492. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  75493. /**
  75494. * The current feature point cloud maintained across frames.
  75495. */
  75496. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  75497. /**
  75498. * construct the feature point system
  75499. * @param _xrSessionManager an instance of xr Session manager
  75500. */
  75501. constructor(_xrSessionManager: WebXRSessionManager);
  75502. /**
  75503. * Detach this feature.
  75504. * Will usually be called by the features manager
  75505. *
  75506. * @returns true if successful.
  75507. */
  75508. detach(): boolean;
  75509. /**
  75510. * Dispose this feature and all of the resources attached
  75511. */
  75512. dispose(): void;
  75513. /**
  75514. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  75515. */
  75516. protected _onXRFrame(frame: XRFrame): void;
  75517. /**
  75518. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  75519. */
  75520. private _init;
  75521. }
  75522. }
  75523. declare module BABYLON {
  75524. /**
  75525. * Configuration interface for the hand tracking feature
  75526. */
  75527. export interface IWebXRHandTrackingOptions {
  75528. /**
  75529. * The xrInput that will be used as source for new hands
  75530. */
  75531. xrInput: WebXRInput;
  75532. /**
  75533. * Configuration object for the joint meshes
  75534. */
  75535. jointMeshes?: {
  75536. /**
  75537. * Should the meshes created be invisible (defaults to false)
  75538. */
  75539. invisible?: boolean;
  75540. /**
  75541. * A source mesh to be used to create instances. Defaults to a sphere.
  75542. * This mesh will be the source for all other (25) meshes.
  75543. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  75544. */
  75545. sourceMesh?: Mesh;
  75546. /**
  75547. * Should the source mesh stay visible. Defaults to false
  75548. */
  75549. keepOriginalVisible?: boolean;
  75550. /**
  75551. * Scale factor for all instances (defaults to 2)
  75552. */
  75553. scaleFactor?: number;
  75554. /**
  75555. * Should each instance have its own physics impostor
  75556. */
  75557. enablePhysics?: boolean;
  75558. /**
  75559. * If enabled, override default physics properties
  75560. */
  75561. physicsProps?: {
  75562. friction?: number;
  75563. restitution?: number;
  75564. impostorType?: number;
  75565. };
  75566. /**
  75567. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  75568. */
  75569. handMesh?: AbstractMesh;
  75570. };
  75571. }
  75572. /**
  75573. * Parts of the hands divided to writs and finger names
  75574. */
  75575. export const enum HandPart {
  75576. /**
  75577. * HandPart - Wrist
  75578. */
  75579. WRIST = "wrist",
  75580. /**
  75581. * HandPart - The THumb
  75582. */
  75583. THUMB = "thumb",
  75584. /**
  75585. * HandPart - Index finger
  75586. */
  75587. INDEX = "index",
  75588. /**
  75589. * HandPart - Middle finger
  75590. */
  75591. MIDDLE = "middle",
  75592. /**
  75593. * HandPart - Ring finger
  75594. */
  75595. RING = "ring",
  75596. /**
  75597. * HandPart - Little finger
  75598. */
  75599. LITTLE = "little"
  75600. }
  75601. /**
  75602. * Representing a single hand (with its corresponding native XRHand object)
  75603. */
  75604. export class WebXRHand implements IDisposable {
  75605. /** the controller to which the hand correlates */
  75606. readonly xrController: WebXRInputSource;
  75607. /** the meshes to be used to track the hand joints */
  75608. readonly trackedMeshes: AbstractMesh[];
  75609. /**
  75610. * Hand-parts definition (key is HandPart)
  75611. */
  75612. handPartsDefinition: {
  75613. [key: string]: number[];
  75614. };
  75615. /**
  75616. * Populate the HandPartsDefinition object.
  75617. * This is called as a side effect since certain browsers don't have XRHand defined.
  75618. */
  75619. private generateHandPartsDefinition;
  75620. /**
  75621. * Construct a new hand object
  75622. * @param xrController the controller to which the hand correlates
  75623. * @param trackedMeshes the meshes to be used to track the hand joints
  75624. */
  75625. constructor(
  75626. /** the controller to which the hand correlates */
  75627. xrController: WebXRInputSource,
  75628. /** the meshes to be used to track the hand joints */
  75629. trackedMeshes: AbstractMesh[]);
  75630. /**
  75631. * Update this hand from the latest xr frame
  75632. * @param xrFrame xrFrame to update from
  75633. * @param referenceSpace The current viewer reference space
  75634. * @param scaleFactor optional scale factor for the meshes
  75635. */
  75636. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  75637. /**
  75638. * Get meshes of part of the hand
  75639. * @param part the part of hand to get
  75640. * @returns An array of meshes that correlate to the hand part requested
  75641. */
  75642. getHandPartMeshes(part: HandPart): AbstractMesh[];
  75643. /**
  75644. * Dispose this Hand object
  75645. */
  75646. dispose(): void;
  75647. }
  75648. /**
  75649. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  75650. */
  75651. export class WebXRHandTracking extends WebXRAbstractFeature {
  75652. /**
  75653. * options to use when constructing this feature
  75654. */
  75655. readonly options: IWebXRHandTrackingOptions;
  75656. private static _idCounter;
  75657. /**
  75658. * The module's name
  75659. */
  75660. static readonly Name: string;
  75661. /**
  75662. * The (Babylon) version of this module.
  75663. * This is an integer representing the implementation version.
  75664. * This number does not correspond to the WebXR specs version
  75665. */
  75666. static readonly Version: number;
  75667. /**
  75668. * This observable will notify registered observers when a new hand object was added and initialized
  75669. */
  75670. onHandAddedObservable: Observable<WebXRHand>;
  75671. /**
  75672. * This observable will notify its observers right before the hand object is disposed
  75673. */
  75674. onHandRemovedObservable: Observable<WebXRHand>;
  75675. private _hands;
  75676. /**
  75677. * Creates a new instance of the hit test feature
  75678. * @param _xrSessionManager an instance of WebXRSessionManager
  75679. * @param options options to use when constructing this feature
  75680. */
  75681. constructor(_xrSessionManager: WebXRSessionManager,
  75682. /**
  75683. * options to use when constructing this feature
  75684. */
  75685. options: IWebXRHandTrackingOptions);
  75686. /**
  75687. * Check if the needed objects are defined.
  75688. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  75689. */
  75690. isCompatible(): boolean;
  75691. /**
  75692. * attach this feature
  75693. * Will usually be called by the features manager
  75694. *
  75695. * @returns true if successful.
  75696. */
  75697. attach(): boolean;
  75698. /**
  75699. * detach this feature.
  75700. * Will usually be called by the features manager
  75701. *
  75702. * @returns true if successful.
  75703. */
  75704. detach(): boolean;
  75705. /**
  75706. * Dispose this feature and all of the resources attached
  75707. */
  75708. dispose(): void;
  75709. /**
  75710. * Get the hand object according to the controller id
  75711. * @param controllerId the controller id to which we want to get the hand
  75712. * @returns null if not found or the WebXRHand object if found
  75713. */
  75714. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  75715. /**
  75716. * Get a hand object according to the requested handedness
  75717. * @param handedness the handedness to request
  75718. * @returns null if not found or the WebXRHand object if found
  75719. */
  75720. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  75721. protected _onXRFrame(_xrFrame: XRFrame): void;
  75722. private _attachHand;
  75723. private _detachHand;
  75724. }
  75725. }
  75726. declare module BABYLON {
  75727. /**
  75728. * The motion controller class for all microsoft mixed reality controllers
  75729. */
  75730. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  75731. protected readonly _mapping: {
  75732. defaultButton: {
  75733. valueNodeName: string;
  75734. unpressedNodeName: string;
  75735. pressedNodeName: string;
  75736. };
  75737. defaultAxis: {
  75738. valueNodeName: string;
  75739. minNodeName: string;
  75740. maxNodeName: string;
  75741. };
  75742. buttons: {
  75743. "xr-standard-trigger": {
  75744. rootNodeName: string;
  75745. componentProperty: string;
  75746. states: string[];
  75747. };
  75748. "xr-standard-squeeze": {
  75749. rootNodeName: string;
  75750. componentProperty: string;
  75751. states: string[];
  75752. };
  75753. "xr-standard-touchpad": {
  75754. rootNodeName: string;
  75755. labelAnchorNodeName: string;
  75756. touchPointNodeName: string;
  75757. };
  75758. "xr-standard-thumbstick": {
  75759. rootNodeName: string;
  75760. componentProperty: string;
  75761. states: string[];
  75762. };
  75763. };
  75764. axes: {
  75765. "xr-standard-touchpad": {
  75766. "x-axis": {
  75767. rootNodeName: string;
  75768. };
  75769. "y-axis": {
  75770. rootNodeName: string;
  75771. };
  75772. };
  75773. "xr-standard-thumbstick": {
  75774. "x-axis": {
  75775. rootNodeName: string;
  75776. };
  75777. "y-axis": {
  75778. rootNodeName: string;
  75779. };
  75780. };
  75781. };
  75782. };
  75783. /**
  75784. * The base url used to load the left and right controller models
  75785. */
  75786. static MODEL_BASE_URL: string;
  75787. /**
  75788. * The name of the left controller model file
  75789. */
  75790. static MODEL_LEFT_FILENAME: string;
  75791. /**
  75792. * The name of the right controller model file
  75793. */
  75794. static MODEL_RIGHT_FILENAME: string;
  75795. profileId: string;
  75796. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  75797. protected _getFilenameAndPath(): {
  75798. filename: string;
  75799. path: string;
  75800. };
  75801. protected _getModelLoadingConstraints(): boolean;
  75802. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75803. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75804. protected _updateModel(): void;
  75805. }
  75806. }
  75807. declare module BABYLON {
  75808. /**
  75809. * The motion controller class for oculus touch (quest, rift).
  75810. * This class supports legacy mapping as well the standard xr mapping
  75811. */
  75812. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  75813. private _forceLegacyControllers;
  75814. private _modelRootNode;
  75815. /**
  75816. * The base url used to load the left and right controller models
  75817. */
  75818. static MODEL_BASE_URL: string;
  75819. /**
  75820. * The name of the left controller model file
  75821. */
  75822. static MODEL_LEFT_FILENAME: string;
  75823. /**
  75824. * The name of the right controller model file
  75825. */
  75826. static MODEL_RIGHT_FILENAME: string;
  75827. /**
  75828. * Base Url for the Quest controller model.
  75829. */
  75830. static QUEST_MODEL_BASE_URL: string;
  75831. profileId: string;
  75832. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  75833. protected _getFilenameAndPath(): {
  75834. filename: string;
  75835. path: string;
  75836. };
  75837. protected _getModelLoadingConstraints(): boolean;
  75838. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75839. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75840. protected _updateModel(): void;
  75841. /**
  75842. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  75843. * between the touch and touch 2.
  75844. */
  75845. private _isQuest;
  75846. }
  75847. }
  75848. declare module BABYLON {
  75849. /**
  75850. * The motion controller class for the standard HTC-Vive controllers
  75851. */
  75852. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  75853. private _modelRootNode;
  75854. /**
  75855. * The base url used to load the left and right controller models
  75856. */
  75857. static MODEL_BASE_URL: string;
  75858. /**
  75859. * File name for the controller model.
  75860. */
  75861. static MODEL_FILENAME: string;
  75862. profileId: string;
  75863. /**
  75864. * Create a new Vive motion controller object
  75865. * @param scene the scene to use to create this controller
  75866. * @param gamepadObject the corresponding gamepad object
  75867. * @param handedness the handedness of the controller
  75868. */
  75869. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  75870. protected _getFilenameAndPath(): {
  75871. filename: string;
  75872. path: string;
  75873. };
  75874. protected _getModelLoadingConstraints(): boolean;
  75875. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75876. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75877. protected _updateModel(): void;
  75878. }
  75879. }
  75880. declare module BABYLON {
  75881. /**
  75882. * A cursor which tracks a point on a path
  75883. */
  75884. export class PathCursor {
  75885. private path;
  75886. /**
  75887. * Stores path cursor callbacks for when an onchange event is triggered
  75888. */
  75889. private _onchange;
  75890. /**
  75891. * The value of the path cursor
  75892. */
  75893. value: number;
  75894. /**
  75895. * The animation array of the path cursor
  75896. */
  75897. animations: Animation[];
  75898. /**
  75899. * Initializes the path cursor
  75900. * @param path The path to track
  75901. */
  75902. constructor(path: Path2);
  75903. /**
  75904. * Gets the cursor point on the path
  75905. * @returns A point on the path cursor at the cursor location
  75906. */
  75907. getPoint(): Vector3;
  75908. /**
  75909. * Moves the cursor ahead by the step amount
  75910. * @param step The amount to move the cursor forward
  75911. * @returns This path cursor
  75912. */
  75913. moveAhead(step?: number): PathCursor;
  75914. /**
  75915. * Moves the cursor behind by the step amount
  75916. * @param step The amount to move the cursor back
  75917. * @returns This path cursor
  75918. */
  75919. moveBack(step?: number): PathCursor;
  75920. /**
  75921. * Moves the cursor by the step amount
  75922. * If the step amount is greater than one, an exception is thrown
  75923. * @param step The amount to move the cursor
  75924. * @returns This path cursor
  75925. */
  75926. move(step: number): PathCursor;
  75927. /**
  75928. * Ensures that the value is limited between zero and one
  75929. * @returns This path cursor
  75930. */
  75931. private ensureLimits;
  75932. /**
  75933. * Runs onchange callbacks on change (used by the animation engine)
  75934. * @returns This path cursor
  75935. */
  75936. private raiseOnChange;
  75937. /**
  75938. * Executes a function on change
  75939. * @param f A path cursor onchange callback
  75940. * @returns This path cursor
  75941. */
  75942. onchange(f: (cursor: PathCursor) => void): PathCursor;
  75943. }
  75944. }
  75945. declare module BABYLON {
  75946. /** @hidden */
  75947. export var blurPixelShader: {
  75948. name: string;
  75949. shader: string;
  75950. };
  75951. }
  75952. declare module BABYLON {
  75953. /** @hidden */
  75954. export var pointCloudVertexDeclaration: {
  75955. name: string;
  75956. shader: string;
  75957. };
  75958. }
  75959. // Mixins
  75960. interface Window {
  75961. mozIndexedDB: IDBFactory;
  75962. webkitIndexedDB: IDBFactory;
  75963. msIndexedDB: IDBFactory;
  75964. webkitURL: typeof URL;
  75965. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  75966. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  75967. WebGLRenderingContext: WebGLRenderingContext;
  75968. MSGesture: MSGesture;
  75969. CANNON: any;
  75970. AudioContext: AudioContext;
  75971. webkitAudioContext: AudioContext;
  75972. PointerEvent: any;
  75973. Math: Math;
  75974. Uint8Array: Uint8ArrayConstructor;
  75975. Float32Array: Float32ArrayConstructor;
  75976. mozURL: typeof URL;
  75977. msURL: typeof URL;
  75978. VRFrameData: any; // WebVR, from specs 1.1
  75979. DracoDecoderModule: any;
  75980. setImmediate(handler: (...args: any[]) => void): number;
  75981. }
  75982. interface HTMLCanvasElement {
  75983. requestPointerLock(): void;
  75984. msRequestPointerLock?(): void;
  75985. mozRequestPointerLock?(): void;
  75986. webkitRequestPointerLock?(): void;
  75987. /** Track wether a record is in progress */
  75988. isRecording: boolean;
  75989. /** Capture Stream method defined by some browsers */
  75990. captureStream(fps?: number): MediaStream;
  75991. }
  75992. interface CanvasRenderingContext2D {
  75993. msImageSmoothingEnabled: boolean;
  75994. }
  75995. interface MouseEvent {
  75996. mozMovementX: number;
  75997. mozMovementY: number;
  75998. webkitMovementX: number;
  75999. webkitMovementY: number;
  76000. msMovementX: number;
  76001. msMovementY: number;
  76002. }
  76003. interface Navigator {
  76004. mozGetVRDevices: (any: any) => any;
  76005. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76006. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76007. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76008. webkitGetGamepads(): Gamepad[];
  76009. msGetGamepads(): Gamepad[];
  76010. webkitGamepads(): Gamepad[];
  76011. }
  76012. interface HTMLVideoElement {
  76013. mozSrcObject: any;
  76014. }
  76015. interface Math {
  76016. fround(x: number): number;
  76017. imul(a: number, b: number): number;
  76018. }
  76019. interface WebGLRenderingContext {
  76020. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  76021. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  76022. vertexAttribDivisor(index: number, divisor: number): void;
  76023. createVertexArray(): any;
  76024. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  76025. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  76026. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  76027. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  76028. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  76029. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  76030. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  76031. // Queries
  76032. createQuery(): WebGLQuery;
  76033. deleteQuery(query: WebGLQuery): void;
  76034. beginQuery(target: number, query: WebGLQuery): void;
  76035. endQuery(target: number): void;
  76036. getQueryParameter(query: WebGLQuery, pname: number): any;
  76037. getQuery(target: number, pname: number): any;
  76038. MAX_SAMPLES: number;
  76039. RGBA8: number;
  76040. READ_FRAMEBUFFER: number;
  76041. DRAW_FRAMEBUFFER: number;
  76042. UNIFORM_BUFFER: number;
  76043. HALF_FLOAT_OES: number;
  76044. RGBA16F: number;
  76045. RGBA32F: number;
  76046. R32F: number;
  76047. RG32F: number;
  76048. RGB32F: number;
  76049. R16F: number;
  76050. RG16F: number;
  76051. RGB16F: number;
  76052. RED: number;
  76053. RG: number;
  76054. R8: number;
  76055. RG8: number;
  76056. UNSIGNED_INT_24_8: number;
  76057. DEPTH24_STENCIL8: number;
  76058. MIN: number;
  76059. MAX: number;
  76060. /* Multiple Render Targets */
  76061. drawBuffers(buffers: number[]): void;
  76062. readBuffer(src: number): void;
  76063. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  76064. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  76065. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  76066. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  76067. // Occlusion Query
  76068. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  76069. ANY_SAMPLES_PASSED: number;
  76070. QUERY_RESULT_AVAILABLE: number;
  76071. QUERY_RESULT: number;
  76072. }
  76073. interface WebGLProgram {
  76074. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  76075. }
  76076. interface EXT_disjoint_timer_query {
  76077. QUERY_COUNTER_BITS_EXT: number;
  76078. TIME_ELAPSED_EXT: number;
  76079. TIMESTAMP_EXT: number;
  76080. GPU_DISJOINT_EXT: number;
  76081. QUERY_RESULT_EXT: number;
  76082. QUERY_RESULT_AVAILABLE_EXT: number;
  76083. queryCounterEXT(query: WebGLQuery, target: number): void;
  76084. createQueryEXT(): WebGLQuery;
  76085. beginQueryEXT(target: number, query: WebGLQuery): void;
  76086. endQueryEXT(target: number): void;
  76087. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  76088. deleteQueryEXT(query: WebGLQuery): void;
  76089. }
  76090. interface WebGLUniformLocation {
  76091. _currentState: any;
  76092. }
  76093. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  76094. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  76095. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  76096. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  76097. interface WebGLRenderingContext {
  76098. readonly RASTERIZER_DISCARD: number;
  76099. readonly DEPTH_COMPONENT24: number;
  76100. readonly TEXTURE_3D: number;
  76101. readonly TEXTURE_2D_ARRAY: number;
  76102. readonly TEXTURE_COMPARE_FUNC: number;
  76103. readonly TEXTURE_COMPARE_MODE: number;
  76104. readonly COMPARE_REF_TO_TEXTURE: number;
  76105. readonly TEXTURE_WRAP_R: number;
  76106. readonly HALF_FLOAT: number;
  76107. readonly RGB8: number;
  76108. readonly RED_INTEGER: number;
  76109. readonly RG_INTEGER: number;
  76110. readonly RGB_INTEGER: number;
  76111. readonly RGBA_INTEGER: number;
  76112. readonly R8_SNORM: number;
  76113. readonly RG8_SNORM: number;
  76114. readonly RGB8_SNORM: number;
  76115. readonly RGBA8_SNORM: number;
  76116. readonly R8I: number;
  76117. readonly RG8I: number;
  76118. readonly RGB8I: number;
  76119. readonly RGBA8I: number;
  76120. readonly R8UI: number;
  76121. readonly RG8UI: number;
  76122. readonly RGB8UI: number;
  76123. readonly RGBA8UI: number;
  76124. readonly R16I: number;
  76125. readonly RG16I: number;
  76126. readonly RGB16I: number;
  76127. readonly RGBA16I: number;
  76128. readonly R16UI: number;
  76129. readonly RG16UI: number;
  76130. readonly RGB16UI: number;
  76131. readonly RGBA16UI: number;
  76132. readonly R32I: number;
  76133. readonly RG32I: number;
  76134. readonly RGB32I: number;
  76135. readonly RGBA32I: number;
  76136. readonly R32UI: number;
  76137. readonly RG32UI: number;
  76138. readonly RGB32UI: number;
  76139. readonly RGBA32UI: number;
  76140. readonly RGB10_A2UI: number;
  76141. readonly R11F_G11F_B10F: number;
  76142. readonly RGB9_E5: number;
  76143. readonly RGB10_A2: number;
  76144. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  76145. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  76146. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  76147. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  76148. readonly DEPTH_COMPONENT32F: number;
  76149. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  76150. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  76151. 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;
  76152. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  76153. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  76154. readonly TRANSFORM_FEEDBACK: number;
  76155. readonly INTERLEAVED_ATTRIBS: number;
  76156. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  76157. createTransformFeedback(): WebGLTransformFeedback;
  76158. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  76159. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  76160. beginTransformFeedback(primitiveMode: number): void;
  76161. endTransformFeedback(): void;
  76162. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  76163. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  76164. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  76165. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  76166. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  76167. }
  76168. interface ImageBitmap {
  76169. readonly width: number;
  76170. readonly height: number;
  76171. close(): void;
  76172. }
  76173. interface WebGLQuery extends WebGLObject {
  76174. }
  76175. declare var WebGLQuery: {
  76176. prototype: WebGLQuery;
  76177. new(): WebGLQuery;
  76178. };
  76179. interface WebGLSampler extends WebGLObject {
  76180. }
  76181. declare var WebGLSampler: {
  76182. prototype: WebGLSampler;
  76183. new(): WebGLSampler;
  76184. };
  76185. interface WebGLSync extends WebGLObject {
  76186. }
  76187. declare var WebGLSync: {
  76188. prototype: WebGLSync;
  76189. new(): WebGLSync;
  76190. };
  76191. interface WebGLTransformFeedback extends WebGLObject {
  76192. }
  76193. declare var WebGLTransformFeedback: {
  76194. prototype: WebGLTransformFeedback;
  76195. new(): WebGLTransformFeedback;
  76196. };
  76197. interface WebGLVertexArrayObject extends WebGLObject {
  76198. }
  76199. declare var WebGLVertexArrayObject: {
  76200. prototype: WebGLVertexArrayObject;
  76201. new(): WebGLVertexArrayObject;
  76202. };
  76203. // Type definitions for WebVR API
  76204. // Project: https://w3c.github.io/webvr/
  76205. // Definitions by: six a <https://github.com/lostfictions>
  76206. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  76207. interface VRDisplay extends EventTarget {
  76208. /**
  76209. * Dictionary of capabilities describing the VRDisplay.
  76210. */
  76211. readonly capabilities: VRDisplayCapabilities;
  76212. /**
  76213. * z-depth defining the far plane of the eye view frustum
  76214. * enables mapping of values in the render target depth
  76215. * attachment to scene coordinates. Initially set to 10000.0.
  76216. */
  76217. depthFar: number;
  76218. /**
  76219. * z-depth defining the near plane of the eye view frustum
  76220. * enables mapping of values in the render target depth
  76221. * attachment to scene coordinates. Initially set to 0.01.
  76222. */
  76223. depthNear: number;
  76224. /**
  76225. * An identifier for this distinct VRDisplay. Used as an
  76226. * association point in the Gamepad API.
  76227. */
  76228. readonly displayId: number;
  76229. /**
  76230. * A display name, a user-readable name identifying it.
  76231. */
  76232. readonly displayName: string;
  76233. readonly isConnected: boolean;
  76234. readonly isPresenting: boolean;
  76235. /**
  76236. * If this VRDisplay supports room-scale experiences, the optional
  76237. * stage attribute contains details on the room-scale parameters.
  76238. */
  76239. readonly stageParameters: VRStageParameters | null;
  76240. /**
  76241. * Passing the value returned by `requestAnimationFrame` to
  76242. * `cancelAnimationFrame` will unregister the callback.
  76243. * @param handle Define the hanle of the request to cancel
  76244. */
  76245. cancelAnimationFrame(handle: number): void;
  76246. /**
  76247. * Stops presenting to the VRDisplay.
  76248. * @returns a promise to know when it stopped
  76249. */
  76250. exitPresent(): Promise<void>;
  76251. /**
  76252. * Return the current VREyeParameters for the given eye.
  76253. * @param whichEye Define the eye we want the parameter for
  76254. * @returns the eye parameters
  76255. */
  76256. getEyeParameters(whichEye: string): VREyeParameters;
  76257. /**
  76258. * Populates the passed VRFrameData with the information required to render
  76259. * the current frame.
  76260. * @param frameData Define the data structure to populate
  76261. * @returns true if ok otherwise false
  76262. */
  76263. getFrameData(frameData: VRFrameData): boolean;
  76264. /**
  76265. * Get the layers currently being presented.
  76266. * @returns the list of VR layers
  76267. */
  76268. getLayers(): VRLayer[];
  76269. /**
  76270. * Return a VRPose containing the future predicted pose of the VRDisplay
  76271. * when the current frame will be presented. The value returned will not
  76272. * change until JavaScript has returned control to the browser.
  76273. *
  76274. * The VRPose will contain the position, orientation, velocity,
  76275. * and acceleration of each of these properties.
  76276. * @returns the pose object
  76277. */
  76278. getPose(): VRPose;
  76279. /**
  76280. * Return the current instantaneous pose of the VRDisplay, with no
  76281. * prediction applied.
  76282. * @returns the current instantaneous pose
  76283. */
  76284. getImmediatePose(): VRPose;
  76285. /**
  76286. * The callback passed to `requestAnimationFrame` will be called
  76287. * any time a new frame should be rendered. When the VRDisplay is
  76288. * presenting the callback will be called at the native refresh
  76289. * rate of the HMD. When not presenting this function acts
  76290. * identically to how window.requestAnimationFrame acts. Content should
  76291. * make no assumptions of frame rate or vsync behavior as the HMD runs
  76292. * asynchronously from other displays and at differing refresh rates.
  76293. * @param callback Define the eaction to run next frame
  76294. * @returns the request handle it
  76295. */
  76296. requestAnimationFrame(callback: FrameRequestCallback): number;
  76297. /**
  76298. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  76299. * Repeat calls while already presenting will update the VRLayers being displayed.
  76300. * @param layers Define the list of layer to present
  76301. * @returns a promise to know when the request has been fulfilled
  76302. */
  76303. requestPresent(layers: VRLayer[]): Promise<void>;
  76304. /**
  76305. * Reset the pose for this display, treating its current position and
  76306. * orientation as the "origin/zero" values. VRPose.position,
  76307. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  76308. * updated when calling resetPose(). This should be called in only
  76309. * sitting-space experiences.
  76310. */
  76311. resetPose(): void;
  76312. /**
  76313. * The VRLayer provided to the VRDisplay will be captured and presented
  76314. * in the HMD. Calling this function has the same effect on the source
  76315. * canvas as any other operation that uses its source image, and canvases
  76316. * created without preserveDrawingBuffer set to true will be cleared.
  76317. * @param pose Define the pose to submit
  76318. */
  76319. submitFrame(pose?: VRPose): void;
  76320. }
  76321. declare var VRDisplay: {
  76322. prototype: VRDisplay;
  76323. new(): VRDisplay;
  76324. };
  76325. interface VRLayer {
  76326. leftBounds?: number[] | Float32Array | null;
  76327. rightBounds?: number[] | Float32Array | null;
  76328. source?: HTMLCanvasElement | null;
  76329. }
  76330. interface VRDisplayCapabilities {
  76331. readonly canPresent: boolean;
  76332. readonly hasExternalDisplay: boolean;
  76333. readonly hasOrientation: boolean;
  76334. readonly hasPosition: boolean;
  76335. readonly maxLayers: number;
  76336. }
  76337. interface VREyeParameters {
  76338. /** @deprecated */
  76339. readonly fieldOfView: VRFieldOfView;
  76340. readonly offset: Float32Array;
  76341. readonly renderHeight: number;
  76342. readonly renderWidth: number;
  76343. }
  76344. interface VRFieldOfView {
  76345. readonly downDegrees: number;
  76346. readonly leftDegrees: number;
  76347. readonly rightDegrees: number;
  76348. readonly upDegrees: number;
  76349. }
  76350. interface VRFrameData {
  76351. readonly leftProjectionMatrix: Float32Array;
  76352. readonly leftViewMatrix: Float32Array;
  76353. readonly pose: VRPose;
  76354. readonly rightProjectionMatrix: Float32Array;
  76355. readonly rightViewMatrix: Float32Array;
  76356. readonly timestamp: number;
  76357. }
  76358. interface VRPose {
  76359. readonly angularAcceleration: Float32Array | null;
  76360. readonly angularVelocity: Float32Array | null;
  76361. readonly linearAcceleration: Float32Array | null;
  76362. readonly linearVelocity: Float32Array | null;
  76363. readonly orientation: Float32Array | null;
  76364. readonly position: Float32Array | null;
  76365. readonly timestamp: number;
  76366. }
  76367. interface VRStageParameters {
  76368. sittingToStandingTransform?: Float32Array;
  76369. sizeX?: number;
  76370. sizeY?: number;
  76371. }
  76372. interface Navigator {
  76373. getVRDisplays(): Promise<VRDisplay[]>;
  76374. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  76375. }
  76376. interface Window {
  76377. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  76378. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  76379. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  76380. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  76381. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  76382. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  76383. }
  76384. interface Gamepad {
  76385. readonly displayId: number;
  76386. }
  76387. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  76388. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  76389. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  76390. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  76391. type XRHandedness = "none" | "left" | "right";
  76392. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  76393. type XREye = "none" | "left" | "right";
  76394. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  76395. interface XRSpace extends EventTarget {}
  76396. interface XRRenderState {
  76397. depthNear?: number;
  76398. depthFar?: number;
  76399. inlineVerticalFieldOfView?: number;
  76400. baseLayer?: XRWebGLLayer;
  76401. }
  76402. interface XRInputSource {
  76403. handedness: XRHandedness;
  76404. targetRayMode: XRTargetRayMode;
  76405. targetRaySpace: XRSpace;
  76406. gripSpace: XRSpace | undefined;
  76407. gamepad: Gamepad | undefined;
  76408. profiles: Array<string>;
  76409. hand: XRHand | undefined;
  76410. }
  76411. interface XRSessionInit {
  76412. optionalFeatures?: string[];
  76413. requiredFeatures?: string[];
  76414. }
  76415. interface XRSession {
  76416. addEventListener: Function;
  76417. removeEventListener: Function;
  76418. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  76419. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  76420. requestAnimationFrame: Function;
  76421. end(): Promise<void>;
  76422. renderState: XRRenderState;
  76423. inputSources: Array<XRInputSource>;
  76424. // hit test
  76425. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  76426. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  76427. // legacy AR hit test
  76428. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  76429. // legacy plane detection
  76430. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  76431. }
  76432. interface XRReferenceSpace extends XRSpace {
  76433. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  76434. onreset: any;
  76435. }
  76436. type XRPlaneSet = Set<XRPlane>;
  76437. type XRAnchorSet = Set<XRAnchor>;
  76438. interface XRFrame {
  76439. session: XRSession;
  76440. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  76441. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  76442. // AR
  76443. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  76444. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  76445. // Anchors
  76446. trackedAnchors?: XRAnchorSet;
  76447. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  76448. // Planes
  76449. worldInformation: {
  76450. detectedPlanes?: XRPlaneSet;
  76451. };
  76452. // Hand tracking
  76453. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  76454. }
  76455. interface XRViewerPose extends XRPose {
  76456. views: Array<XRView>;
  76457. }
  76458. interface XRPose {
  76459. transform: XRRigidTransform;
  76460. emulatedPosition: boolean;
  76461. }
  76462. interface XRWebGLLayerOptions {
  76463. antialias?: boolean;
  76464. depth?: boolean;
  76465. stencil?: boolean;
  76466. alpha?: boolean;
  76467. multiview?: boolean;
  76468. framebufferScaleFactor?: number;
  76469. }
  76470. declare var XRWebGLLayer: {
  76471. prototype: XRWebGLLayer;
  76472. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  76473. };
  76474. interface XRWebGLLayer {
  76475. framebuffer: WebGLFramebuffer;
  76476. framebufferWidth: number;
  76477. framebufferHeight: number;
  76478. getViewport: Function;
  76479. }
  76480. declare class XRRigidTransform {
  76481. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  76482. position: DOMPointReadOnly;
  76483. orientation: DOMPointReadOnly;
  76484. matrix: Float32Array;
  76485. inverse: XRRigidTransform;
  76486. }
  76487. interface XRView {
  76488. eye: XREye;
  76489. projectionMatrix: Float32Array;
  76490. transform: XRRigidTransform;
  76491. }
  76492. interface XRInputSourceChangeEvent {
  76493. session: XRSession;
  76494. removed: Array<XRInputSource>;
  76495. added: Array<XRInputSource>;
  76496. }
  76497. interface XRInputSourceEvent extends Event {
  76498. readonly frame: XRFrame;
  76499. readonly inputSource: XRInputSource;
  76500. }
  76501. // Experimental(er) features
  76502. declare class XRRay {
  76503. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  76504. origin: DOMPointReadOnly;
  76505. direction: DOMPointReadOnly;
  76506. matrix: Float32Array;
  76507. }
  76508. declare enum XRHitTestTrackableType {
  76509. "point",
  76510. "plane",
  76511. "mesh",
  76512. }
  76513. interface XRHitResult {
  76514. hitMatrix: Float32Array;
  76515. }
  76516. interface XRTransientInputHitTestResult {
  76517. readonly inputSource: XRInputSource;
  76518. readonly results: Array<XRHitTestResult>;
  76519. }
  76520. interface XRHitTestResult {
  76521. getPose(baseSpace: XRSpace): XRPose | undefined;
  76522. // When anchor system is enabled
  76523. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  76524. }
  76525. interface XRHitTestSource {
  76526. cancel(): void;
  76527. }
  76528. interface XRTransientInputHitTestSource {
  76529. cancel(): void;
  76530. }
  76531. interface XRHitTestOptionsInit {
  76532. space: XRSpace;
  76533. entityTypes?: Array<XRHitTestTrackableType>;
  76534. offsetRay?: XRRay;
  76535. }
  76536. interface XRTransientInputHitTestOptionsInit {
  76537. profile: string;
  76538. entityTypes?: Array<XRHitTestTrackableType>;
  76539. offsetRay?: XRRay;
  76540. }
  76541. interface XRAnchor {
  76542. anchorSpace: XRSpace;
  76543. delete(): void;
  76544. }
  76545. interface XRPlane {
  76546. orientation: "Horizontal" | "Vertical";
  76547. planeSpace: XRSpace;
  76548. polygon: Array<DOMPointReadOnly>;
  76549. lastChangedTime: number;
  76550. }
  76551. interface XRJointSpace extends XRSpace {}
  76552. interface XRJointPose extends XRPose {
  76553. radius: number | undefined;
  76554. }
  76555. interface XRHand /*extends Iterablele<XRJointSpace>*/ {
  76556. readonly length: number;
  76557. [index: number]: XRJointSpace;
  76558. // Specs have the function 'joint(idx: number)', but chrome doesn't support it yet.
  76559. readonly WRIST: number;
  76560. readonly THUMB_METACARPAL: number;
  76561. readonly THUMB_PHALANX_PROXIMAL: number;
  76562. readonly THUMB_PHALANX_DISTAL: number;
  76563. readonly THUMB_PHALANX_TIP: number;
  76564. readonly INDEX_METACARPAL: number;
  76565. readonly INDEX_PHALANX_PROXIMAL: number;
  76566. readonly INDEX_PHALANX_INTERMEDIATE: number;
  76567. readonly INDEX_PHALANX_DISTAL: number;
  76568. readonly INDEX_PHALANX_TIP: number;
  76569. readonly MIDDLE_METACARPAL: number;
  76570. readonly MIDDLE_PHALANX_PROXIMAL: number;
  76571. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  76572. readonly MIDDLE_PHALANX_DISTAL: number;
  76573. readonly MIDDLE_PHALANX_TIP: number;
  76574. readonly RING_METACARPAL: number;
  76575. readonly RING_PHALANX_PROXIMAL: number;
  76576. readonly RING_PHALANX_INTERMEDIATE: number;
  76577. readonly RING_PHALANX_DISTAL: number;
  76578. readonly RING_PHALANX_TIP: number;
  76579. readonly LITTLE_METACARPAL: number;
  76580. readonly LITTLE_PHALANX_PROXIMAL: number;
  76581. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  76582. readonly LITTLE_PHALANX_DISTAL: number;
  76583. readonly LITTLE_PHALANX_TIP: number;
  76584. }
  76585. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  76586. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  76587. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  76588. interface XRSession {
  76589. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  76590. }
  76591. interface XRFrame {
  76592. featurePointCloud? : Array<number>;
  76593. }
  76594. /**
  76595. * @ignore
  76596. */
  76597. declare module BABYLON.GLTF2.Exporter {
  76598. }
  76599. /**
  76600. * @ignore
  76601. */
  76602. declare module BABYLON.GLTF1 {
  76603. }
  76604. declare module BABYLON.GUI {
  76605. /**
  76606. * Class used to specific a value and its associated unit
  76607. */
  76608. export class ValueAndUnit {
  76609. /** defines the unit to store */
  76610. unit: number;
  76611. /** defines a boolean indicating if the value can be negative */
  76612. negativeValueAllowed: boolean;
  76613. private _value;
  76614. private _originalUnit;
  76615. /**
  76616. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  76617. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76618. */
  76619. ignoreAdaptiveScaling: boolean;
  76620. /**
  76621. * Creates a new ValueAndUnit
  76622. * @param value defines the value to store
  76623. * @param unit defines the unit to store
  76624. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  76625. */
  76626. constructor(value: number,
  76627. /** defines the unit to store */
  76628. unit?: number,
  76629. /** defines a boolean indicating if the value can be negative */
  76630. negativeValueAllowed?: boolean);
  76631. /** Gets a boolean indicating if the value is a percentage */
  76632. get isPercentage(): boolean;
  76633. /** Gets a boolean indicating if the value is store as pixel */
  76634. get isPixel(): boolean;
  76635. /** Gets direct internal value */
  76636. get internalValue(): number;
  76637. /**
  76638. * Gets value as pixel
  76639. * @param host defines the root host
  76640. * @param refValue defines the reference value for percentages
  76641. * @returns the value as pixel
  76642. */
  76643. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  76644. /**
  76645. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  76646. * @param value defines the value to store
  76647. * @param unit defines the unit to store
  76648. * @returns the current ValueAndUnit
  76649. */
  76650. updateInPlace(value: number, unit?: number): ValueAndUnit;
  76651. /**
  76652. * Gets the value accordingly to its unit
  76653. * @param host defines the root host
  76654. * @returns the value
  76655. */
  76656. getValue(host: AdvancedDynamicTexture): number;
  76657. /**
  76658. * Gets a string representation of the value
  76659. * @param host defines the root host
  76660. * @param decimals defines an optional number of decimals to display
  76661. * @returns a string
  76662. */
  76663. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  76664. /**
  76665. * Store a value parsed from a string
  76666. * @param source defines the source string
  76667. * @returns true if the value was successfully parsed
  76668. */
  76669. fromString(source: string | number): boolean;
  76670. private static _Regex;
  76671. private static _UNITMODE_PERCENTAGE;
  76672. private static _UNITMODE_PIXEL;
  76673. /** UNITMODE_PERCENTAGE */
  76674. static get UNITMODE_PERCENTAGE(): number;
  76675. /** UNITMODE_PIXEL */
  76676. static get UNITMODE_PIXEL(): number;
  76677. }
  76678. }
  76679. declare module BABYLON.GUI {
  76680. /**
  76681. * Define a style used by control to automatically setup properties based on a template.
  76682. * Only support font related properties so far
  76683. */
  76684. export class Style implements BABYLON.IDisposable {
  76685. private _fontFamily;
  76686. private _fontStyle;
  76687. private _fontWeight;
  76688. /** @hidden */
  76689. _host: AdvancedDynamicTexture;
  76690. /** @hidden */
  76691. _fontSize: ValueAndUnit;
  76692. /**
  76693. * BABYLON.Observable raised when the style values are changed
  76694. */
  76695. onChangedObservable: BABYLON.Observable<Style>;
  76696. /**
  76697. * Creates a new style object
  76698. * @param host defines the AdvancedDynamicTexture which hosts this style
  76699. */
  76700. constructor(host: AdvancedDynamicTexture);
  76701. /**
  76702. * Gets or sets the font size
  76703. */
  76704. get fontSize(): string | number;
  76705. set fontSize(value: string | number);
  76706. /**
  76707. * Gets or sets the font family
  76708. */
  76709. get fontFamily(): string;
  76710. set fontFamily(value: string);
  76711. /**
  76712. * Gets or sets the font style
  76713. */
  76714. get fontStyle(): string;
  76715. set fontStyle(value: string);
  76716. /** Gets or sets font weight */
  76717. get fontWeight(): string;
  76718. set fontWeight(value: string);
  76719. /** Dispose all associated resources */
  76720. dispose(): void;
  76721. }
  76722. }
  76723. declare module BABYLON.GUI {
  76724. /**
  76725. * Class used to transport BABYLON.Vector2 information for pointer events
  76726. */
  76727. export class Vector2WithInfo extends BABYLON.Vector2 {
  76728. /** defines the current mouse button index */
  76729. buttonIndex: number;
  76730. /**
  76731. * Creates a new Vector2WithInfo
  76732. * @param source defines the vector2 data to transport
  76733. * @param buttonIndex defines the current mouse button index
  76734. */
  76735. constructor(source: BABYLON.Vector2,
  76736. /** defines the current mouse button index */
  76737. buttonIndex?: number);
  76738. }
  76739. /** Class used to provide 2D matrix features */
  76740. export class Matrix2D {
  76741. /** Gets the internal array of 6 floats used to store matrix data */
  76742. m: Float32Array;
  76743. /**
  76744. * Creates a new matrix
  76745. * @param m00 defines value for (0, 0)
  76746. * @param m01 defines value for (0, 1)
  76747. * @param m10 defines value for (1, 0)
  76748. * @param m11 defines value for (1, 1)
  76749. * @param m20 defines value for (2, 0)
  76750. * @param m21 defines value for (2, 1)
  76751. */
  76752. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  76753. /**
  76754. * Fills the matrix from direct values
  76755. * @param m00 defines value for (0, 0)
  76756. * @param m01 defines value for (0, 1)
  76757. * @param m10 defines value for (1, 0)
  76758. * @param m11 defines value for (1, 1)
  76759. * @param m20 defines value for (2, 0)
  76760. * @param m21 defines value for (2, 1)
  76761. * @returns the current modified matrix
  76762. */
  76763. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  76764. /**
  76765. * Gets matrix determinant
  76766. * @returns the determinant
  76767. */
  76768. determinant(): number;
  76769. /**
  76770. * Inverses the matrix and stores it in a target matrix
  76771. * @param result defines the target matrix
  76772. * @returns the current matrix
  76773. */
  76774. invertToRef(result: Matrix2D): Matrix2D;
  76775. /**
  76776. * Multiplies the current matrix with another one
  76777. * @param other defines the second operand
  76778. * @param result defines the target matrix
  76779. * @returns the current matrix
  76780. */
  76781. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  76782. /**
  76783. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  76784. * @param x defines the x coordinate to transform
  76785. * @param y defines the x coordinate to transform
  76786. * @param result defines the target vector2
  76787. * @returns the current matrix
  76788. */
  76789. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  76790. /**
  76791. * Creates an identity matrix
  76792. * @returns a new matrix
  76793. */
  76794. static Identity(): Matrix2D;
  76795. /**
  76796. * Creates a translation matrix and stores it in a target matrix
  76797. * @param x defines the x coordinate of the translation
  76798. * @param y defines the y coordinate of the translation
  76799. * @param result defines the target matrix
  76800. */
  76801. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  76802. /**
  76803. * Creates a scaling matrix and stores it in a target matrix
  76804. * @param x defines the x coordinate of the scaling
  76805. * @param y defines the y coordinate of the scaling
  76806. * @param result defines the target matrix
  76807. */
  76808. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  76809. /**
  76810. * Creates a rotation matrix and stores it in a target matrix
  76811. * @param angle defines the rotation angle
  76812. * @param result defines the target matrix
  76813. */
  76814. static RotationToRef(angle: number, result: Matrix2D): void;
  76815. private static _TempPreTranslationMatrix;
  76816. private static _TempPostTranslationMatrix;
  76817. private static _TempRotationMatrix;
  76818. private static _TempScalingMatrix;
  76819. private static _TempCompose0;
  76820. private static _TempCompose1;
  76821. private static _TempCompose2;
  76822. /**
  76823. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  76824. * @param tx defines the x coordinate of the translation
  76825. * @param ty defines the y coordinate of the translation
  76826. * @param angle defines the rotation angle
  76827. * @param scaleX defines the x coordinate of the scaling
  76828. * @param scaleY defines the y coordinate of the scaling
  76829. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  76830. * @param result defines the target matrix
  76831. */
  76832. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  76833. }
  76834. }
  76835. declare module BABYLON.GUI {
  76836. /**
  76837. * Class used to store 2D control sizes
  76838. */
  76839. export class Measure {
  76840. /** defines left coordinate */
  76841. left: number;
  76842. /** defines top coordinate */
  76843. top: number;
  76844. /** defines width dimension */
  76845. width: number;
  76846. /** defines height dimension */
  76847. height: number;
  76848. /**
  76849. * Creates a new measure
  76850. * @param left defines left coordinate
  76851. * @param top defines top coordinate
  76852. * @param width defines width dimension
  76853. * @param height defines height dimension
  76854. */
  76855. constructor(
  76856. /** defines left coordinate */
  76857. left: number,
  76858. /** defines top coordinate */
  76859. top: number,
  76860. /** defines width dimension */
  76861. width: number,
  76862. /** defines height dimension */
  76863. height: number);
  76864. /**
  76865. * Copy from another measure
  76866. * @param other defines the other measure to copy from
  76867. */
  76868. copyFrom(other: Measure): void;
  76869. /**
  76870. * Copy from a group of 4 floats
  76871. * @param left defines left coordinate
  76872. * @param top defines top coordinate
  76873. * @param width defines width dimension
  76874. * @param height defines height dimension
  76875. */
  76876. copyFromFloats(left: number, top: number, width: number, height: number): void;
  76877. /**
  76878. * Computes the axis aligned bounding box measure for two given measures
  76879. * @param a Input measure
  76880. * @param b Input measure
  76881. * @param result the resulting bounding measure
  76882. */
  76883. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  76884. /**
  76885. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  76886. * @param transform the matrix to transform the measure before computing the AABB
  76887. * @param addX number to add to left
  76888. * @param addY number to add to top
  76889. * @param addWidth number to add to width
  76890. * @param addHeight number to add to height
  76891. * @param result the resulting AABB
  76892. */
  76893. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  76894. /**
  76895. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  76896. * @param transform the matrix to transform the measure before computing the AABB
  76897. * @param result the resulting AABB
  76898. */
  76899. transformToRef(transform: Matrix2D, result: Measure): void;
  76900. /**
  76901. * Check equality between this measure and another one
  76902. * @param other defines the other measures
  76903. * @returns true if both measures are equals
  76904. */
  76905. isEqualsTo(other: Measure): boolean;
  76906. /**
  76907. * Creates an empty measure
  76908. * @returns a new measure
  76909. */
  76910. static Empty(): Measure;
  76911. }
  76912. }
  76913. declare module BABYLON.GUI {
  76914. /**
  76915. * Interface used to define a control that can receive focus
  76916. */
  76917. export interface IFocusableControl {
  76918. /**
  76919. * Function called when the control receives the focus
  76920. */
  76921. onFocus(): void;
  76922. /**
  76923. * Function called when the control loses the focus
  76924. */
  76925. onBlur(): void;
  76926. /**
  76927. * Function called to let the control handle keyboard events
  76928. * @param evt defines the current keyboard event
  76929. */
  76930. processKeyboard(evt: KeyboardEvent): void;
  76931. /**
  76932. * Function called to get the list of controls that should not steal the focus from this control
  76933. * @returns an array of controls
  76934. */
  76935. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  76936. }
  76937. /**
  76938. * Class used to create texture to support 2D GUI elements
  76939. * @see https://doc.babylonjs.com/how_to/gui
  76940. */
  76941. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  76942. private _isDirty;
  76943. private _renderObserver;
  76944. private _resizeObserver;
  76945. private _preKeyboardObserver;
  76946. private _pointerMoveObserver;
  76947. private _pointerObserver;
  76948. private _canvasPointerOutObserver;
  76949. private _canvasBlurObserver;
  76950. private _background;
  76951. /** @hidden */
  76952. _rootContainer: Container;
  76953. /** @hidden */
  76954. _lastPickedControl: Control;
  76955. /** @hidden */
  76956. _lastControlOver: {
  76957. [pointerId: number]: Control;
  76958. };
  76959. /** @hidden */
  76960. _lastControlDown: {
  76961. [pointerId: number]: Control;
  76962. };
  76963. /** @hidden */
  76964. _capturingControl: {
  76965. [pointerId: number]: Control;
  76966. };
  76967. /** @hidden */
  76968. _shouldBlockPointer: boolean;
  76969. /** @hidden */
  76970. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  76971. /** @hidden */
  76972. _linkedControls: Control[];
  76973. private _isFullscreen;
  76974. private _fullscreenViewport;
  76975. private _idealWidth;
  76976. private _idealHeight;
  76977. private _useSmallestIdeal;
  76978. private _renderAtIdealSize;
  76979. private _focusedControl;
  76980. private _blockNextFocusCheck;
  76981. private _renderScale;
  76982. private _rootElement;
  76983. private _cursorChanged;
  76984. private _defaultMousePointerId;
  76985. /** @hidden */
  76986. _numLayoutCalls: number;
  76987. /** Gets the number of layout calls made the last time the ADT has been rendered */
  76988. get numLayoutCalls(): number;
  76989. /** @hidden */
  76990. _numRenderCalls: number;
  76991. /** Gets the number of render calls made the last time the ADT has been rendered */
  76992. get numRenderCalls(): number;
  76993. /**
  76994. * Define type to string to ensure compatibility across browsers
  76995. * Safari doesn't support DataTransfer constructor
  76996. */
  76997. private _clipboardData;
  76998. /**
  76999. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  77000. */
  77001. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  77002. /**
  77003. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  77004. */
  77005. onControlPickedObservable: BABYLON.Observable<Control>;
  77006. /**
  77007. * BABYLON.Observable event triggered before layout is evaluated
  77008. */
  77009. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77010. /**
  77011. * BABYLON.Observable event triggered after the layout was evaluated
  77012. */
  77013. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77014. /**
  77015. * BABYLON.Observable event triggered before the texture is rendered
  77016. */
  77017. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77018. /**
  77019. * BABYLON.Observable event triggered after the texture was rendered
  77020. */
  77021. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77022. /**
  77023. * Gets or sets a boolean defining if alpha is stored as premultiplied
  77024. */
  77025. premulAlpha: boolean;
  77026. /**
  77027. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  77028. * Useful when you want more antialiasing
  77029. */
  77030. get renderScale(): number;
  77031. set renderScale(value: number);
  77032. /** Gets or sets the background color */
  77033. get background(): string;
  77034. set background(value: string);
  77035. /**
  77036. * Gets or sets the ideal width used to design controls.
  77037. * The GUI will then rescale everything accordingly
  77038. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77039. */
  77040. get idealWidth(): number;
  77041. set idealWidth(value: number);
  77042. /**
  77043. * Gets or sets the ideal height used to design controls.
  77044. * The GUI will then rescale everything accordingly
  77045. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77046. */
  77047. get idealHeight(): number;
  77048. set idealHeight(value: number);
  77049. /**
  77050. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  77051. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77052. */
  77053. get useSmallestIdeal(): boolean;
  77054. set useSmallestIdeal(value: boolean);
  77055. /**
  77056. * Gets or sets a boolean indicating if adaptive scaling must be used
  77057. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77058. */
  77059. get renderAtIdealSize(): boolean;
  77060. set renderAtIdealSize(value: boolean);
  77061. /**
  77062. * Gets the ratio used when in "ideal mode"
  77063. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77064. * */
  77065. get idealRatio(): number;
  77066. /**
  77067. * Gets the underlying layer used to render the texture when in fullscreen mode
  77068. */
  77069. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  77070. /**
  77071. * Gets the root container control
  77072. */
  77073. get rootContainer(): Container;
  77074. /**
  77075. * Returns an array containing the root container.
  77076. * This is mostly used to let the Inspector introspects the ADT
  77077. * @returns an array containing the rootContainer
  77078. */
  77079. getChildren(): Array<Container>;
  77080. /**
  77081. * Will return all controls that are inside this texture
  77082. * @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
  77083. * @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
  77084. * @return all child controls
  77085. */
  77086. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  77087. /**
  77088. * Gets or sets the current focused control
  77089. */
  77090. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  77091. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  77092. /**
  77093. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  77094. */
  77095. get isForeground(): boolean;
  77096. set isForeground(value: boolean);
  77097. /**
  77098. * Gets or set information about clipboardData
  77099. */
  77100. get clipboardData(): string;
  77101. set clipboardData(value: string);
  77102. /**
  77103. * Creates a new AdvancedDynamicTexture
  77104. * @param name defines the name of the texture
  77105. * @param width defines the width of the texture
  77106. * @param height defines the height of the texture
  77107. * @param scene defines the hosting scene
  77108. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  77109. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  77110. */
  77111. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  77112. /**
  77113. * Get the current class name of the texture useful for serialization or dynamic coding.
  77114. * @returns "AdvancedDynamicTexture"
  77115. */
  77116. getClassName(): string;
  77117. /**
  77118. * Function used to execute a function on all controls
  77119. * @param func defines the function to execute
  77120. * @param container defines the container where controls belong. If null the root container will be used
  77121. */
  77122. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  77123. private _useInvalidateRectOptimization;
  77124. /**
  77125. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  77126. */
  77127. get useInvalidateRectOptimization(): boolean;
  77128. set useInvalidateRectOptimization(value: boolean);
  77129. private _invalidatedRectangle;
  77130. /**
  77131. * Invalidates a rectangle area on the gui texture
  77132. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  77133. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  77134. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  77135. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  77136. */
  77137. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  77138. /**
  77139. * Marks the texture as dirty forcing a complete update
  77140. */
  77141. markAsDirty(): void;
  77142. /**
  77143. * Helper function used to create a new style
  77144. * @returns a new style
  77145. * @see https://doc.babylonjs.com/how_to/gui#styles
  77146. */
  77147. createStyle(): Style;
  77148. /**
  77149. * Adds a new control to the root container
  77150. * @param control defines the control to add
  77151. * @returns the current texture
  77152. */
  77153. addControl(control: Control): AdvancedDynamicTexture;
  77154. /**
  77155. * Removes a control from the root container
  77156. * @param control defines the control to remove
  77157. * @returns the current texture
  77158. */
  77159. removeControl(control: Control): AdvancedDynamicTexture;
  77160. /**
  77161. * Release all resources
  77162. */
  77163. dispose(): void;
  77164. private _onResize;
  77165. /** @hidden */
  77166. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  77167. /**
  77168. * Get screen coordinates for a vector3
  77169. * @param position defines the position to project
  77170. * @param worldMatrix defines the world matrix to use
  77171. * @returns the projected position
  77172. */
  77173. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  77174. private _checkUpdate;
  77175. private _clearMeasure;
  77176. private _render;
  77177. /** @hidden */
  77178. _changeCursor(cursor: string): void;
  77179. /** @hidden */
  77180. _registerLastControlDown(control: Control, pointerId: number): void;
  77181. private _doPicking;
  77182. /** @hidden */
  77183. _cleanControlAfterRemovalFromList(list: {
  77184. [pointerId: number]: Control;
  77185. }, control: Control): void;
  77186. /** @hidden */
  77187. _cleanControlAfterRemoval(control: Control): void;
  77188. /** Attach to all scene events required to support pointer events */
  77189. attach(): void;
  77190. /** @hidden */
  77191. private onClipboardCopy;
  77192. /** @hidden */
  77193. private onClipboardCut;
  77194. /** @hidden */
  77195. private onClipboardPaste;
  77196. /**
  77197. * Register the clipboard Events onto the canvas
  77198. */
  77199. registerClipboardEvents(): void;
  77200. /**
  77201. * Unregister the clipboard Events from the canvas
  77202. */
  77203. unRegisterClipboardEvents(): void;
  77204. /**
  77205. * Connect the texture to a hosting mesh to enable interactions
  77206. * @param mesh defines the mesh to attach to
  77207. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  77208. */
  77209. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  77210. /**
  77211. * Move the focus to a specific control
  77212. * @param control defines the control which will receive the focus
  77213. */
  77214. moveFocusToControl(control: IFocusableControl): void;
  77215. private _manageFocus;
  77216. private _attachToOnPointerOut;
  77217. private _attachToOnBlur;
  77218. /**
  77219. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  77220. * @param mesh defines the mesh which will receive the texture
  77221. * @param width defines the texture width (1024 by default)
  77222. * @param height defines the texture height (1024 by default)
  77223. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  77224. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  77225. * @returns a new AdvancedDynamicTexture
  77226. */
  77227. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  77228. /**
  77229. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  77230. * In this mode the texture will rely on a layer for its rendering.
  77231. * This allows it to be treated like any other layer.
  77232. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  77233. * LayerMask is set through advancedTexture.layer.layerMask
  77234. * @param name defines name for the texture
  77235. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  77236. * @param scene defines the hsoting scene
  77237. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  77238. * @returns a new AdvancedDynamicTexture
  77239. */
  77240. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  77241. }
  77242. }
  77243. declare module BABYLON.GUI {
  77244. /**
  77245. * Root class used for all 2D controls
  77246. * @see https://doc.babylonjs.com/how_to/gui#controls
  77247. */
  77248. export class Control {
  77249. /** defines the name of the control */
  77250. name?: string | undefined;
  77251. /**
  77252. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  77253. */
  77254. static AllowAlphaInheritance: boolean;
  77255. private _alpha;
  77256. private _alphaSet;
  77257. private _zIndex;
  77258. /** @hidden */
  77259. _host: AdvancedDynamicTexture;
  77260. /** Gets or sets the control parent */
  77261. parent: BABYLON.Nullable<Container>;
  77262. /** @hidden */
  77263. _currentMeasure: Measure;
  77264. private _fontFamily;
  77265. private _fontStyle;
  77266. private _fontWeight;
  77267. private _fontSize;
  77268. private _font;
  77269. /** @hidden */
  77270. _width: ValueAndUnit;
  77271. /** @hidden */
  77272. _height: ValueAndUnit;
  77273. /** @hidden */
  77274. protected _fontOffset: {
  77275. ascent: number;
  77276. height: number;
  77277. descent: number;
  77278. };
  77279. private _color;
  77280. private _style;
  77281. private _styleObserver;
  77282. /** @hidden */
  77283. protected _horizontalAlignment: number;
  77284. /** @hidden */
  77285. protected _verticalAlignment: number;
  77286. /** @hidden */
  77287. protected _isDirty: boolean;
  77288. /** @hidden */
  77289. protected _wasDirty: boolean;
  77290. /** @hidden */
  77291. _tempParentMeasure: Measure;
  77292. /** @hidden */
  77293. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  77294. /** @hidden */
  77295. protected _cachedParentMeasure: Measure;
  77296. private _paddingLeft;
  77297. private _paddingRight;
  77298. private _paddingTop;
  77299. private _paddingBottom;
  77300. /** @hidden */
  77301. _left: ValueAndUnit;
  77302. /** @hidden */
  77303. _top: ValueAndUnit;
  77304. private _scaleX;
  77305. private _scaleY;
  77306. private _rotation;
  77307. private _transformCenterX;
  77308. private _transformCenterY;
  77309. /** @hidden */
  77310. _transformMatrix: Matrix2D;
  77311. /** @hidden */
  77312. protected _invertTransformMatrix: Matrix2D;
  77313. /** @hidden */
  77314. protected _transformedPosition: BABYLON.Vector2;
  77315. private _isMatrixDirty;
  77316. private _cachedOffsetX;
  77317. private _cachedOffsetY;
  77318. private _isVisible;
  77319. private _isHighlighted;
  77320. /** @hidden */
  77321. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  77322. private _fontSet;
  77323. private _dummyVector2;
  77324. private _downCount;
  77325. private _enterCount;
  77326. private _doNotRender;
  77327. private _downPointerIds;
  77328. protected _isEnabled: boolean;
  77329. protected _disabledColor: string;
  77330. protected _disabledColorItem: string;
  77331. /** @hidden */
  77332. protected _rebuildLayout: boolean;
  77333. /** @hidden */
  77334. _customData: any;
  77335. /** @hidden */
  77336. _isClipped: boolean;
  77337. /** @hidden */
  77338. _automaticSize: boolean;
  77339. /** @hidden */
  77340. _tag: any;
  77341. /**
  77342. * 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
  77343. */
  77344. uniqueId: number;
  77345. /**
  77346. * Gets or sets an object used to store user defined information for the node
  77347. */
  77348. metadata: any;
  77349. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  77350. isHitTestVisible: boolean;
  77351. /** Gets or sets a boolean indicating if the control can block pointer events */
  77352. isPointerBlocker: boolean;
  77353. /** Gets or sets a boolean indicating if the control can be focusable */
  77354. isFocusInvisible: boolean;
  77355. /**
  77356. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  77357. * 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
  77358. */
  77359. clipChildren: boolean;
  77360. /**
  77361. * Gets or sets a boolean indicating that control content must be clipped
  77362. * 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
  77363. */
  77364. clipContent: boolean;
  77365. /**
  77366. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  77367. */
  77368. useBitmapCache: boolean;
  77369. private _cacheData;
  77370. private _shadowOffsetX;
  77371. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  77372. get shadowOffsetX(): number;
  77373. set shadowOffsetX(value: number);
  77374. private _shadowOffsetY;
  77375. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  77376. get shadowOffsetY(): number;
  77377. set shadowOffsetY(value: number);
  77378. private _shadowBlur;
  77379. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  77380. get shadowBlur(): number;
  77381. set shadowBlur(value: number);
  77382. private _shadowColor;
  77383. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  77384. get shadowColor(): string;
  77385. set shadowColor(value: string);
  77386. /** Gets or sets the cursor to use when the control is hovered */
  77387. hoverCursor: string;
  77388. /** @hidden */
  77389. protected _linkOffsetX: ValueAndUnit;
  77390. /** @hidden */
  77391. protected _linkOffsetY: ValueAndUnit;
  77392. /** Gets the control type name */
  77393. get typeName(): string;
  77394. /**
  77395. * Get the current class name of the control.
  77396. * @returns current class name
  77397. */
  77398. getClassName(): string;
  77399. /**
  77400. * An event triggered when pointer wheel is scrolled
  77401. */
  77402. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  77403. /**
  77404. * An event triggered when the pointer move over the control.
  77405. */
  77406. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  77407. /**
  77408. * An event triggered when the pointer move out of the control.
  77409. */
  77410. onPointerOutObservable: BABYLON.Observable<Control>;
  77411. /**
  77412. * An event triggered when the pointer taps the control
  77413. */
  77414. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  77415. /**
  77416. * An event triggered when pointer up
  77417. */
  77418. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  77419. /**
  77420. * An event triggered when a control is clicked on
  77421. */
  77422. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  77423. /**
  77424. * An event triggered when pointer enters the control
  77425. */
  77426. onPointerEnterObservable: BABYLON.Observable<Control>;
  77427. /**
  77428. * An event triggered when the control is marked as dirty
  77429. */
  77430. onDirtyObservable: BABYLON.Observable<Control>;
  77431. /**
  77432. * An event triggered before drawing the control
  77433. */
  77434. onBeforeDrawObservable: BABYLON.Observable<Control>;
  77435. /**
  77436. * An event triggered after the control was drawn
  77437. */
  77438. onAfterDrawObservable: BABYLON.Observable<Control>;
  77439. /**
  77440. * An event triggered when the control has been disposed
  77441. */
  77442. onDisposeObservable: BABYLON.Observable<Control>;
  77443. /**
  77444. * Get the hosting AdvancedDynamicTexture
  77445. */
  77446. get host(): AdvancedDynamicTexture;
  77447. /** Gets or set information about font offsets (used to render and align text) */
  77448. get fontOffset(): {
  77449. ascent: number;
  77450. height: number;
  77451. descent: number;
  77452. };
  77453. set fontOffset(offset: {
  77454. ascent: number;
  77455. height: number;
  77456. descent: number;
  77457. });
  77458. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  77459. get alpha(): number;
  77460. set alpha(value: number);
  77461. /**
  77462. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  77463. */
  77464. get isHighlighted(): boolean;
  77465. set isHighlighted(value: boolean);
  77466. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  77467. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77468. */
  77469. get scaleX(): number;
  77470. set scaleX(value: number);
  77471. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  77472. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77473. */
  77474. get scaleY(): number;
  77475. set scaleY(value: number);
  77476. /** Gets or sets the rotation angle (0 by default)
  77477. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77478. */
  77479. get rotation(): number;
  77480. set rotation(value: number);
  77481. /** Gets or sets the transformation center on Y axis (0 by default)
  77482. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77483. */
  77484. get transformCenterY(): number;
  77485. set transformCenterY(value: number);
  77486. /** Gets or sets the transformation center on X axis (0 by default)
  77487. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77488. */
  77489. get transformCenterX(): number;
  77490. set transformCenterX(value: number);
  77491. /**
  77492. * Gets or sets the horizontal alignment
  77493. * @see https://doc.babylonjs.com/how_to/gui#alignments
  77494. */
  77495. get horizontalAlignment(): number;
  77496. set horizontalAlignment(value: number);
  77497. /**
  77498. * Gets or sets the vertical alignment
  77499. * @see https://doc.babylonjs.com/how_to/gui#alignments
  77500. */
  77501. get verticalAlignment(): number;
  77502. set verticalAlignment(value: number);
  77503. /**
  77504. * Gets or sets a fixed ratio for this control.
  77505. * When different from 0, the ratio is used to compute the "second" dimension.
  77506. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  77507. * second dimension is computed as first dimension * fixedRatio
  77508. */
  77509. fixedRatio: number;
  77510. private _fixedRatioMasterIsWidth;
  77511. /**
  77512. * Gets or sets control width
  77513. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77514. */
  77515. get width(): string | number;
  77516. set width(value: string | number);
  77517. /**
  77518. * Gets or sets the control width in pixel
  77519. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77520. */
  77521. get widthInPixels(): number;
  77522. set widthInPixels(value: number);
  77523. /**
  77524. * Gets or sets control height
  77525. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77526. */
  77527. get height(): string | number;
  77528. set height(value: string | number);
  77529. /**
  77530. * Gets or sets control height in pixel
  77531. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77532. */
  77533. get heightInPixels(): number;
  77534. set heightInPixels(value: number);
  77535. /** Gets or set font family */
  77536. get fontFamily(): string;
  77537. set fontFamily(value: string);
  77538. /** Gets or sets font style */
  77539. get fontStyle(): string;
  77540. set fontStyle(value: string);
  77541. /** Gets or sets font weight */
  77542. get fontWeight(): string;
  77543. set fontWeight(value: string);
  77544. /**
  77545. * Gets or sets style
  77546. * @see https://doc.babylonjs.com/how_to/gui#styles
  77547. */
  77548. get style(): BABYLON.Nullable<Style>;
  77549. set style(value: BABYLON.Nullable<Style>);
  77550. /** @hidden */
  77551. get _isFontSizeInPercentage(): boolean;
  77552. /** Gets or sets font size in pixels */
  77553. get fontSizeInPixels(): number;
  77554. set fontSizeInPixels(value: number);
  77555. /** Gets or sets font size */
  77556. get fontSize(): string | number;
  77557. set fontSize(value: string | number);
  77558. /** Gets or sets foreground color */
  77559. get color(): string;
  77560. set color(value: string);
  77561. /** Gets or sets z index which is used to reorder controls on the z axis */
  77562. get zIndex(): number;
  77563. set zIndex(value: number);
  77564. /** Gets or sets a boolean indicating if the control can be rendered */
  77565. get notRenderable(): boolean;
  77566. set notRenderable(value: boolean);
  77567. /** Gets or sets a boolean indicating if the control is visible */
  77568. get isVisible(): boolean;
  77569. set isVisible(value: boolean);
  77570. /** Gets a boolean indicating that the control needs to update its rendering */
  77571. get isDirty(): boolean;
  77572. /**
  77573. * Gets the current linked mesh (or null if none)
  77574. */
  77575. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  77576. /**
  77577. * Gets or sets a value indicating the padding to use on the left of the control
  77578. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77579. */
  77580. get paddingLeft(): string | number;
  77581. set paddingLeft(value: string | number);
  77582. /**
  77583. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  77584. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77585. */
  77586. get paddingLeftInPixels(): number;
  77587. set paddingLeftInPixels(value: number);
  77588. /**
  77589. * Gets or sets a value indicating the padding to use on the right of the control
  77590. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77591. */
  77592. get paddingRight(): string | number;
  77593. set paddingRight(value: string | number);
  77594. /**
  77595. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  77596. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77597. */
  77598. get paddingRightInPixels(): number;
  77599. set paddingRightInPixels(value: number);
  77600. /**
  77601. * Gets or sets a value indicating the padding to use on the top of the control
  77602. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77603. */
  77604. get paddingTop(): string | number;
  77605. set paddingTop(value: string | number);
  77606. /**
  77607. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  77608. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77609. */
  77610. get paddingTopInPixels(): number;
  77611. set paddingTopInPixels(value: number);
  77612. /**
  77613. * Gets or sets a value indicating the padding to use on the bottom of the control
  77614. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77615. */
  77616. get paddingBottom(): string | number;
  77617. set paddingBottom(value: string | number);
  77618. /**
  77619. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  77620. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77621. */
  77622. get paddingBottomInPixels(): number;
  77623. set paddingBottomInPixels(value: number);
  77624. /**
  77625. * Gets or sets a value indicating the left coordinate of the control
  77626. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77627. */
  77628. get left(): string | number;
  77629. set left(value: string | number);
  77630. /**
  77631. * Gets or sets a value indicating the left coordinate in pixels of the control
  77632. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77633. */
  77634. get leftInPixels(): number;
  77635. set leftInPixels(value: number);
  77636. /**
  77637. * Gets or sets a value indicating the top coordinate of the control
  77638. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77639. */
  77640. get top(): string | number;
  77641. set top(value: string | number);
  77642. /**
  77643. * Gets or sets a value indicating the top coordinate in pixels of the control
  77644. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77645. */
  77646. get topInPixels(): number;
  77647. set topInPixels(value: number);
  77648. /**
  77649. * Gets or sets a value indicating the offset on X axis to the linked mesh
  77650. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77651. */
  77652. get linkOffsetX(): string | number;
  77653. set linkOffsetX(value: string | number);
  77654. /**
  77655. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  77656. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77657. */
  77658. get linkOffsetXInPixels(): number;
  77659. set linkOffsetXInPixels(value: number);
  77660. /**
  77661. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  77662. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77663. */
  77664. get linkOffsetY(): string | number;
  77665. set linkOffsetY(value: string | number);
  77666. /**
  77667. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  77668. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77669. */
  77670. get linkOffsetYInPixels(): number;
  77671. set linkOffsetYInPixels(value: number);
  77672. /** Gets the center coordinate on X axis */
  77673. get centerX(): number;
  77674. /** Gets the center coordinate on Y axis */
  77675. get centerY(): number;
  77676. /** Gets or sets if control is Enabled*/
  77677. get isEnabled(): boolean;
  77678. set isEnabled(value: boolean);
  77679. /** Gets or sets background color of control if it's disabled*/
  77680. get disabledColor(): string;
  77681. set disabledColor(value: string);
  77682. /** Gets or sets front color of control if it's disabled*/
  77683. get disabledColorItem(): string;
  77684. set disabledColorItem(value: string);
  77685. /**
  77686. * Creates a new control
  77687. * @param name defines the name of the control
  77688. */
  77689. constructor(
  77690. /** defines the name of the control */
  77691. name?: string | undefined);
  77692. /** @hidden */
  77693. protected _getTypeName(): string;
  77694. /**
  77695. * Gets the first ascendant in the hierarchy of the given type
  77696. * @param className defines the required type
  77697. * @returns the ascendant or null if not found
  77698. */
  77699. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  77700. /** @hidden */
  77701. _resetFontCache(): void;
  77702. /**
  77703. * Determines if a container is an ascendant of the current control
  77704. * @param container defines the container to look for
  77705. * @returns true if the container is one of the ascendant of the control
  77706. */
  77707. isAscendant(container: Control): boolean;
  77708. /**
  77709. * Gets coordinates in local control space
  77710. * @param globalCoordinates defines the coordinates to transform
  77711. * @returns the new coordinates in local space
  77712. */
  77713. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  77714. /**
  77715. * Gets coordinates in local control space
  77716. * @param globalCoordinates defines the coordinates to transform
  77717. * @param result defines the target vector2 where to store the result
  77718. * @returns the current control
  77719. */
  77720. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  77721. /**
  77722. * Gets coordinates in parent local control space
  77723. * @param globalCoordinates defines the coordinates to transform
  77724. * @returns the new coordinates in parent local space
  77725. */
  77726. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  77727. /**
  77728. * Move the current control to a vector3 position projected onto the screen.
  77729. * @param position defines the target position
  77730. * @param scene defines the hosting scene
  77731. */
  77732. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  77733. /**
  77734. * Will store all controls that have this control as ascendant in a given array
  77735. * @param results defines the array where to store the descendants
  77736. * @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
  77737. * @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
  77738. */
  77739. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  77740. /**
  77741. * Will return all controls that have this control as ascendant
  77742. * @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
  77743. * @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
  77744. * @return all child controls
  77745. */
  77746. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  77747. /**
  77748. * Link current control with a target mesh
  77749. * @param mesh defines the mesh to link with
  77750. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77751. */
  77752. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  77753. /** @hidden */
  77754. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  77755. /** @hidden */
  77756. _offsetLeft(offset: number): void;
  77757. /** @hidden */
  77758. _offsetTop(offset: number): void;
  77759. /** @hidden */
  77760. _markMatrixAsDirty(): void;
  77761. /** @hidden */
  77762. _flagDescendantsAsMatrixDirty(): void;
  77763. /** @hidden */
  77764. _intersectsRect(rect: Measure): boolean;
  77765. /** @hidden */
  77766. protected invalidateRect(): void;
  77767. /** @hidden */
  77768. _markAsDirty(force?: boolean): void;
  77769. /** @hidden */
  77770. _markAllAsDirty(): void;
  77771. /** @hidden */
  77772. _link(host: AdvancedDynamicTexture): void;
  77773. /** @hidden */
  77774. protected _transform(context?: CanvasRenderingContext2D): void;
  77775. /** @hidden */
  77776. _renderHighlight(context: CanvasRenderingContext2D): void;
  77777. /** @hidden */
  77778. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  77779. /** @hidden */
  77780. protected _applyStates(context: CanvasRenderingContext2D): void;
  77781. /** @hidden */
  77782. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  77783. /** @hidden */
  77784. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77785. protected _evaluateClippingState(parentMeasure: Measure): void;
  77786. /** @hidden */
  77787. _measure(): void;
  77788. /** @hidden */
  77789. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77790. /** @hidden */
  77791. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77792. /** @hidden */
  77793. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77794. /** @hidden */
  77795. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  77796. private static _ClipMeasure;
  77797. private _tmpMeasureA;
  77798. private _clip;
  77799. /** @hidden */
  77800. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  77801. /** @hidden */
  77802. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77803. /**
  77804. * Tests if a given coordinates belong to the current control
  77805. * @param x defines x coordinate to test
  77806. * @param y defines y coordinate to test
  77807. * @returns true if the coordinates are inside the control
  77808. */
  77809. contains(x: number, y: number): boolean;
  77810. /** @hidden */
  77811. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  77812. /** @hidden */
  77813. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  77814. /** @hidden */
  77815. _onPointerEnter(target: Control): boolean;
  77816. /** @hidden */
  77817. _onPointerOut(target: Control, force?: boolean): void;
  77818. /** @hidden */
  77819. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77820. /** @hidden */
  77821. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77822. /** @hidden */
  77823. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  77824. /** @hidden */
  77825. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  77826. /** @hidden */
  77827. _onCanvasBlur(): void;
  77828. /** @hidden */
  77829. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  77830. private _prepareFont;
  77831. /** Releases associated resources */
  77832. dispose(): void;
  77833. private static _HORIZONTAL_ALIGNMENT_LEFT;
  77834. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  77835. private static _HORIZONTAL_ALIGNMENT_CENTER;
  77836. private static _VERTICAL_ALIGNMENT_TOP;
  77837. private static _VERTICAL_ALIGNMENT_BOTTOM;
  77838. private static _VERTICAL_ALIGNMENT_CENTER;
  77839. /** HORIZONTAL_ALIGNMENT_LEFT */
  77840. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  77841. /** HORIZONTAL_ALIGNMENT_RIGHT */
  77842. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  77843. /** HORIZONTAL_ALIGNMENT_CENTER */
  77844. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  77845. /** VERTICAL_ALIGNMENT_TOP */
  77846. static get VERTICAL_ALIGNMENT_TOP(): number;
  77847. /** VERTICAL_ALIGNMENT_BOTTOM */
  77848. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  77849. /** VERTICAL_ALIGNMENT_CENTER */
  77850. static get VERTICAL_ALIGNMENT_CENTER(): number;
  77851. private static _FontHeightSizes;
  77852. /** @hidden */
  77853. static _GetFontOffset(font: string): {
  77854. ascent: number;
  77855. height: number;
  77856. descent: number;
  77857. };
  77858. /**
  77859. * Creates a stack panel that can be used to render headers
  77860. * @param control defines the control to associate with the header
  77861. * @param text defines the text of the header
  77862. * @param size defines the size of the header
  77863. * @param options defines options used to configure the header
  77864. * @returns a new StackPanel
  77865. * @ignore
  77866. * @hidden
  77867. */
  77868. static AddHeader: (control: Control, text: string, size: string | number, options: {
  77869. isHorizontal: boolean;
  77870. controlFirst: boolean;
  77871. }) => any;
  77872. /** @hidden */
  77873. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  77874. }
  77875. }
  77876. declare module BABYLON.GUI {
  77877. /**
  77878. * Root class for 2D containers
  77879. * @see https://doc.babylonjs.com/how_to/gui#containers
  77880. */
  77881. export class Container extends Control {
  77882. name?: string | undefined;
  77883. /** @hidden */
  77884. _children: Control[];
  77885. /** @hidden */
  77886. protected _measureForChildren: Measure;
  77887. /** @hidden */
  77888. protected _background: string;
  77889. /** @hidden */
  77890. protected _adaptWidthToChildren: boolean;
  77891. /** @hidden */
  77892. protected _adaptHeightToChildren: boolean;
  77893. /**
  77894. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  77895. */
  77896. logLayoutCycleErrors: boolean;
  77897. /**
  77898. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  77899. */
  77900. maxLayoutCycle: number;
  77901. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  77902. get adaptHeightToChildren(): boolean;
  77903. set adaptHeightToChildren(value: boolean);
  77904. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  77905. get adaptWidthToChildren(): boolean;
  77906. set adaptWidthToChildren(value: boolean);
  77907. /** Gets or sets background color */
  77908. get background(): string;
  77909. set background(value: string);
  77910. /** Gets the list of children */
  77911. get children(): Control[];
  77912. /**
  77913. * Creates a new Container
  77914. * @param name defines the name of the container
  77915. */
  77916. constructor(name?: string | undefined);
  77917. protected _getTypeName(): string;
  77918. _flagDescendantsAsMatrixDirty(): void;
  77919. /**
  77920. * Gets a child using its name
  77921. * @param name defines the child name to look for
  77922. * @returns the child control if found
  77923. */
  77924. getChildByName(name: string): BABYLON.Nullable<Control>;
  77925. /**
  77926. * Gets a child using its type and its name
  77927. * @param name defines the child name to look for
  77928. * @param type defines the child type to look for
  77929. * @returns the child control if found
  77930. */
  77931. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  77932. /**
  77933. * Search for a specific control in children
  77934. * @param control defines the control to look for
  77935. * @returns true if the control is in child list
  77936. */
  77937. containsControl(control: Control): boolean;
  77938. /**
  77939. * Adds a new control to the current container
  77940. * @param control defines the control to add
  77941. * @returns the current container
  77942. */
  77943. addControl(control: BABYLON.Nullable<Control>): Container;
  77944. /**
  77945. * Removes all controls from the current container
  77946. * @returns the current container
  77947. */
  77948. clearControls(): Container;
  77949. /**
  77950. * Removes a control from the current container
  77951. * @param control defines the control to remove
  77952. * @returns the current container
  77953. */
  77954. removeControl(control: Control): Container;
  77955. /** @hidden */
  77956. _reOrderControl(control: Control): void;
  77957. /** @hidden */
  77958. _offsetLeft(offset: number): void;
  77959. /** @hidden */
  77960. _offsetTop(offset: number): void;
  77961. /** @hidden */
  77962. _markAllAsDirty(): void;
  77963. /** @hidden */
  77964. protected _localDraw(context: CanvasRenderingContext2D): void;
  77965. /** @hidden */
  77966. _link(host: AdvancedDynamicTexture): void;
  77967. /** @hidden */
  77968. protected _beforeLayout(): void;
  77969. /** @hidden */
  77970. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77971. /** @hidden */
  77972. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  77973. protected _postMeasure(): void;
  77974. /** @hidden */
  77975. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  77976. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  77977. /** @hidden */
  77978. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  77979. /** @hidden */
  77980. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77981. /** Releases associated resources */
  77982. dispose(): void;
  77983. }
  77984. }
  77985. declare module BABYLON.GUI {
  77986. /** Class used to create rectangle container */
  77987. export class Rectangle extends Container {
  77988. name?: string | undefined;
  77989. private _thickness;
  77990. private _cornerRadius;
  77991. /** Gets or sets border thickness */
  77992. get thickness(): number;
  77993. set thickness(value: number);
  77994. /** Gets or sets the corner radius angle */
  77995. get cornerRadius(): number;
  77996. set cornerRadius(value: number);
  77997. /**
  77998. * Creates a new Rectangle
  77999. * @param name defines the control name
  78000. */
  78001. constructor(name?: string | undefined);
  78002. protected _getTypeName(): string;
  78003. protected _localDraw(context: CanvasRenderingContext2D): void;
  78004. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78005. private _drawRoundedRect;
  78006. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  78007. }
  78008. }
  78009. declare module BABYLON.GUI {
  78010. /**
  78011. * Enum that determines the text-wrapping mode to use.
  78012. */
  78013. export enum TextWrapping {
  78014. /**
  78015. * Clip the text when it's larger than Control.width; this is the default mode.
  78016. */
  78017. Clip = 0,
  78018. /**
  78019. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  78020. */
  78021. WordWrap = 1,
  78022. /**
  78023. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  78024. */
  78025. Ellipsis = 2
  78026. }
  78027. /**
  78028. * Class used to create text block control
  78029. */
  78030. export class TextBlock extends Control {
  78031. /**
  78032. * Defines the name of the control
  78033. */
  78034. name?: string | undefined;
  78035. private _text;
  78036. private _textWrapping;
  78037. private _textHorizontalAlignment;
  78038. private _textVerticalAlignment;
  78039. private _lines;
  78040. private _resizeToFit;
  78041. private _lineSpacing;
  78042. private _outlineWidth;
  78043. private _outlineColor;
  78044. private _underline;
  78045. private _lineThrough;
  78046. /**
  78047. * An event triggered after the text is changed
  78048. */
  78049. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  78050. /**
  78051. * An event triggered after the text was broken up into lines
  78052. */
  78053. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  78054. /**
  78055. * Function used to split a string into words. By default, a string is split at each space character found
  78056. */
  78057. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  78058. /**
  78059. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  78060. */
  78061. get lines(): any[];
  78062. /**
  78063. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  78064. */
  78065. get resizeToFit(): boolean;
  78066. /**
  78067. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  78068. */
  78069. set resizeToFit(value: boolean);
  78070. /**
  78071. * Gets or sets a boolean indicating if text must be wrapped
  78072. */
  78073. get textWrapping(): TextWrapping | boolean;
  78074. /**
  78075. * Gets or sets a boolean indicating if text must be wrapped
  78076. */
  78077. set textWrapping(value: TextWrapping | boolean);
  78078. /**
  78079. * Gets or sets text to display
  78080. */
  78081. get text(): string;
  78082. /**
  78083. * Gets or sets text to display
  78084. */
  78085. set text(value: string);
  78086. /**
  78087. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  78088. */
  78089. get textHorizontalAlignment(): number;
  78090. /**
  78091. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  78092. */
  78093. set textHorizontalAlignment(value: number);
  78094. /**
  78095. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  78096. */
  78097. get textVerticalAlignment(): number;
  78098. /**
  78099. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  78100. */
  78101. set textVerticalAlignment(value: number);
  78102. /**
  78103. * Gets or sets line spacing value
  78104. */
  78105. set lineSpacing(value: string | number);
  78106. /**
  78107. * Gets or sets line spacing value
  78108. */
  78109. get lineSpacing(): string | number;
  78110. /**
  78111. * Gets or sets outlineWidth of the text to display
  78112. */
  78113. get outlineWidth(): number;
  78114. /**
  78115. * Gets or sets outlineWidth of the text to display
  78116. */
  78117. set outlineWidth(value: number);
  78118. /**
  78119. * Gets or sets a boolean indicating that text must have underline
  78120. */
  78121. get underline(): boolean;
  78122. /**
  78123. * Gets or sets a boolean indicating that text must have underline
  78124. */
  78125. set underline(value: boolean);
  78126. /**
  78127. * Gets or sets an boolean indicating that text must be crossed out
  78128. */
  78129. get lineThrough(): boolean;
  78130. /**
  78131. * Gets or sets an boolean indicating that text must be crossed out
  78132. */
  78133. set lineThrough(value: boolean);
  78134. /**
  78135. * Gets or sets outlineColor of the text to display
  78136. */
  78137. get outlineColor(): string;
  78138. /**
  78139. * Gets or sets outlineColor of the text to display
  78140. */
  78141. set outlineColor(value: string);
  78142. /**
  78143. * Creates a new TextBlock object
  78144. * @param name defines the name of the control
  78145. * @param text defines the text to display (emptry string by default)
  78146. */
  78147. constructor(
  78148. /**
  78149. * Defines the name of the control
  78150. */
  78151. name?: string | undefined, text?: string);
  78152. protected _getTypeName(): string;
  78153. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78154. private _drawText;
  78155. /** @hidden */
  78156. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78157. protected _applyStates(context: CanvasRenderingContext2D): void;
  78158. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  78159. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  78160. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  78161. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  78162. protected _renderLines(context: CanvasRenderingContext2D): void;
  78163. /**
  78164. * Given a width constraint applied on the text block, find the expected height
  78165. * @returns expected height
  78166. */
  78167. computeExpectedHeight(): number;
  78168. dispose(): void;
  78169. }
  78170. }
  78171. declare module BABYLON.GUI {
  78172. /**
  78173. * Class used to create 2D images
  78174. */
  78175. export class Image extends Control {
  78176. name?: string | undefined;
  78177. private _workingCanvas;
  78178. private _domImage;
  78179. private _imageWidth;
  78180. private _imageHeight;
  78181. private _loaded;
  78182. private _stretch;
  78183. private _source;
  78184. private _autoScale;
  78185. private _sourceLeft;
  78186. private _sourceTop;
  78187. private _sourceWidth;
  78188. private _sourceHeight;
  78189. private _svgAttributesComputationCompleted;
  78190. private _isSVG;
  78191. private _cellWidth;
  78192. private _cellHeight;
  78193. private _cellId;
  78194. private _populateNinePatchSlicesFromImage;
  78195. private _sliceLeft;
  78196. private _sliceRight;
  78197. private _sliceTop;
  78198. private _sliceBottom;
  78199. private _detectPointerOnOpaqueOnly;
  78200. private _imageDataCache;
  78201. /**
  78202. * BABYLON.Observable notified when the content is loaded
  78203. */
  78204. onImageLoadedObservable: BABYLON.Observable<Image>;
  78205. /**
  78206. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  78207. */
  78208. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  78209. /**
  78210. * Gets a boolean indicating that the content is loaded
  78211. */
  78212. get isLoaded(): boolean;
  78213. /**
  78214. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  78215. */
  78216. get populateNinePatchSlicesFromImage(): boolean;
  78217. set populateNinePatchSlicesFromImage(value: boolean);
  78218. /**
  78219. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  78220. * Beware using this as this will comsume more memory as the image has to be stored twice
  78221. */
  78222. get detectPointerOnOpaqueOnly(): boolean;
  78223. set detectPointerOnOpaqueOnly(value: boolean);
  78224. /**
  78225. * Gets or sets the left value for slicing (9-patch)
  78226. */
  78227. get sliceLeft(): number;
  78228. set sliceLeft(value: number);
  78229. /**
  78230. * Gets or sets the right value for slicing (9-patch)
  78231. */
  78232. get sliceRight(): number;
  78233. set sliceRight(value: number);
  78234. /**
  78235. * Gets or sets the top value for slicing (9-patch)
  78236. */
  78237. get sliceTop(): number;
  78238. set sliceTop(value: number);
  78239. /**
  78240. * Gets or sets the bottom value for slicing (9-patch)
  78241. */
  78242. get sliceBottom(): number;
  78243. set sliceBottom(value: number);
  78244. /**
  78245. * Gets or sets the left coordinate in the source image
  78246. */
  78247. get sourceLeft(): number;
  78248. set sourceLeft(value: number);
  78249. /**
  78250. * Gets or sets the top coordinate in the source image
  78251. */
  78252. get sourceTop(): number;
  78253. set sourceTop(value: number);
  78254. /**
  78255. * Gets or sets the width to capture in the source image
  78256. */
  78257. get sourceWidth(): number;
  78258. set sourceWidth(value: number);
  78259. /**
  78260. * Gets or sets the height to capture in the source image
  78261. */
  78262. get sourceHeight(): number;
  78263. set sourceHeight(value: number);
  78264. /** Indicates if the format of the image is SVG */
  78265. get isSVG(): boolean;
  78266. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  78267. get svgAttributesComputationCompleted(): boolean;
  78268. /**
  78269. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  78270. * @see https://doc.babylonjs.com/how_to/gui#image
  78271. */
  78272. get autoScale(): boolean;
  78273. set autoScale(value: boolean);
  78274. /** Gets or sets the streching mode used by the image */
  78275. get stretch(): number;
  78276. set stretch(value: number);
  78277. /** @hidden */
  78278. _rotate90(n: number, preserveProperties?: boolean): Image;
  78279. private _handleRotationForSVGImage;
  78280. private _rotate90SourceProperties;
  78281. /**
  78282. * Gets or sets the internal DOM image used to render the control
  78283. */
  78284. set domImage(value: HTMLImageElement);
  78285. get domImage(): HTMLImageElement;
  78286. private _onImageLoaded;
  78287. private _extractNinePatchSliceDataFromImage;
  78288. /**
  78289. * Gets or sets image source url
  78290. */
  78291. set source(value: BABYLON.Nullable<string>);
  78292. /**
  78293. * Checks for svg document with icon id present
  78294. */
  78295. private _svgCheck;
  78296. /**
  78297. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  78298. * given external svg file and icon id
  78299. */
  78300. private _getSVGAttribs;
  78301. /**
  78302. * Gets or sets the cell width to use when animation sheet is enabled
  78303. * @see https://doc.babylonjs.com/how_to/gui#image
  78304. */
  78305. get cellWidth(): number;
  78306. set cellWidth(value: number);
  78307. /**
  78308. * Gets or sets the cell height to use when animation sheet is enabled
  78309. * @see https://doc.babylonjs.com/how_to/gui#image
  78310. */
  78311. get cellHeight(): number;
  78312. set cellHeight(value: number);
  78313. /**
  78314. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  78315. * @see https://doc.babylonjs.com/how_to/gui#image
  78316. */
  78317. get cellId(): number;
  78318. set cellId(value: number);
  78319. /**
  78320. * Creates a new Image
  78321. * @param name defines the control name
  78322. * @param url defines the image url
  78323. */
  78324. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  78325. /**
  78326. * Tests if a given coordinates belong to the current control
  78327. * @param x defines x coordinate to test
  78328. * @param y defines y coordinate to test
  78329. * @returns true if the coordinates are inside the control
  78330. */
  78331. contains(x: number, y: number): boolean;
  78332. protected _getTypeName(): string;
  78333. /** Force the control to synchronize with its content */
  78334. synchronizeSizeWithContent(): void;
  78335. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78336. private _prepareWorkingCanvasForOpaqueDetection;
  78337. private _drawImage;
  78338. _draw(context: CanvasRenderingContext2D): void;
  78339. private _renderCornerPatch;
  78340. private _renderNinePatch;
  78341. dispose(): void;
  78342. /** STRETCH_NONE */
  78343. static readonly STRETCH_NONE: number;
  78344. /** STRETCH_FILL */
  78345. static readonly STRETCH_FILL: number;
  78346. /** STRETCH_UNIFORM */
  78347. static readonly STRETCH_UNIFORM: number;
  78348. /** STRETCH_EXTEND */
  78349. static readonly STRETCH_EXTEND: number;
  78350. /** NINE_PATCH */
  78351. static readonly STRETCH_NINE_PATCH: number;
  78352. }
  78353. }
  78354. declare module BABYLON.GUI {
  78355. /**
  78356. * Class used to create 2D buttons
  78357. */
  78358. export class Button extends Rectangle {
  78359. name?: string | undefined;
  78360. /**
  78361. * Function called to generate a pointer enter animation
  78362. */
  78363. pointerEnterAnimation: () => void;
  78364. /**
  78365. * Function called to generate a pointer out animation
  78366. */
  78367. pointerOutAnimation: () => void;
  78368. /**
  78369. * Function called to generate a pointer down animation
  78370. */
  78371. pointerDownAnimation: () => void;
  78372. /**
  78373. * Function called to generate a pointer up animation
  78374. */
  78375. pointerUpAnimation: () => void;
  78376. /**
  78377. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  78378. */
  78379. delegatePickingToChildren: boolean;
  78380. private _image;
  78381. /**
  78382. * Returns the image part of the button (if any)
  78383. */
  78384. get image(): BABYLON.Nullable<Image>;
  78385. private _textBlock;
  78386. /**
  78387. * Returns the image part of the button (if any)
  78388. */
  78389. get textBlock(): BABYLON.Nullable<TextBlock>;
  78390. /**
  78391. * Creates a new Button
  78392. * @param name defines the name of the button
  78393. */
  78394. constructor(name?: string | undefined);
  78395. protected _getTypeName(): string;
  78396. /** @hidden */
  78397. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78398. /** @hidden */
  78399. _onPointerEnter(target: Control): boolean;
  78400. /** @hidden */
  78401. _onPointerOut(target: Control, force?: boolean): void;
  78402. /** @hidden */
  78403. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78404. /** @hidden */
  78405. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78406. /**
  78407. * Creates a new button made with an image and a text
  78408. * @param name defines the name of the button
  78409. * @param text defines the text of the button
  78410. * @param imageUrl defines the url of the image
  78411. * @returns a new Button
  78412. */
  78413. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  78414. /**
  78415. * Creates a new button made with an image
  78416. * @param name defines the name of the button
  78417. * @param imageUrl defines the url of the image
  78418. * @returns a new Button
  78419. */
  78420. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  78421. /**
  78422. * Creates a new button made with a text
  78423. * @param name defines the name of the button
  78424. * @param text defines the text of the button
  78425. * @returns a new Button
  78426. */
  78427. static CreateSimpleButton(name: string, text: string): Button;
  78428. /**
  78429. * Creates a new button made with an image and a centered text
  78430. * @param name defines the name of the button
  78431. * @param text defines the text of the button
  78432. * @param imageUrl defines the url of the image
  78433. * @returns a new Button
  78434. */
  78435. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  78436. }
  78437. }
  78438. declare module BABYLON.GUI {
  78439. /**
  78440. * Class used to create a 2D stack panel container
  78441. */
  78442. export class StackPanel extends Container {
  78443. name?: string | undefined;
  78444. private _isVertical;
  78445. private _manualWidth;
  78446. private _manualHeight;
  78447. private _doNotTrackManualChanges;
  78448. /**
  78449. * Gets or sets a boolean indicating that layou warnings should be ignored
  78450. */
  78451. ignoreLayoutWarnings: boolean;
  78452. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  78453. get isVertical(): boolean;
  78454. set isVertical(value: boolean);
  78455. /**
  78456. * Gets or sets panel width.
  78457. * This value should not be set when in horizontal mode as it will be computed automatically
  78458. */
  78459. set width(value: string | number);
  78460. get width(): string | number;
  78461. /**
  78462. * Gets or sets panel height.
  78463. * This value should not be set when in vertical mode as it will be computed automatically
  78464. */
  78465. set height(value: string | number);
  78466. get height(): string | number;
  78467. /**
  78468. * Creates a new StackPanel
  78469. * @param name defines control name
  78470. */
  78471. constructor(name?: string | undefined);
  78472. protected _getTypeName(): string;
  78473. /** @hidden */
  78474. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78475. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78476. protected _postMeasure(): void;
  78477. }
  78478. }
  78479. declare module BABYLON.GUI {
  78480. /**
  78481. * Class used to represent a 2D checkbox
  78482. */
  78483. export class Checkbox extends Control {
  78484. name?: string | undefined;
  78485. private _isChecked;
  78486. private _background;
  78487. private _checkSizeRatio;
  78488. private _thickness;
  78489. /** Gets or sets border thickness */
  78490. get thickness(): number;
  78491. set thickness(value: number);
  78492. /**
  78493. * BABYLON.Observable raised when isChecked property changes
  78494. */
  78495. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  78496. /** Gets or sets a value indicating the ratio between overall size and check size */
  78497. get checkSizeRatio(): number;
  78498. set checkSizeRatio(value: number);
  78499. /** Gets or sets background color */
  78500. get background(): string;
  78501. set background(value: string);
  78502. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  78503. get isChecked(): boolean;
  78504. set isChecked(value: boolean);
  78505. /**
  78506. * Creates a new CheckBox
  78507. * @param name defines the control name
  78508. */
  78509. constructor(name?: string | undefined);
  78510. protected _getTypeName(): string;
  78511. /** @hidden */
  78512. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78513. /** @hidden */
  78514. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78515. /**
  78516. * Utility function to easily create a checkbox with a header
  78517. * @param title defines the label to use for the header
  78518. * @param onValueChanged defines the callback to call when value changes
  78519. * @returns a StackPanel containing the checkbox and a textBlock
  78520. */
  78521. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  78522. }
  78523. }
  78524. declare module BABYLON.GUI {
  78525. /**
  78526. * Class used to store key control properties
  78527. */
  78528. export class KeyPropertySet {
  78529. /** Width */
  78530. width?: string;
  78531. /** Height */
  78532. height?: string;
  78533. /** Left padding */
  78534. paddingLeft?: string;
  78535. /** Right padding */
  78536. paddingRight?: string;
  78537. /** Top padding */
  78538. paddingTop?: string;
  78539. /** Bottom padding */
  78540. paddingBottom?: string;
  78541. /** Foreground color */
  78542. color?: string;
  78543. /** Background color */
  78544. background?: string;
  78545. }
  78546. /**
  78547. * Class used to create virtual keyboard
  78548. */
  78549. export class VirtualKeyboard extends StackPanel {
  78550. /** BABYLON.Observable raised when a key is pressed */
  78551. onKeyPressObservable: BABYLON.Observable<string>;
  78552. /** Gets or sets default key button width */
  78553. defaultButtonWidth: string;
  78554. /** Gets or sets default key button height */
  78555. defaultButtonHeight: string;
  78556. /** Gets or sets default key button left padding */
  78557. defaultButtonPaddingLeft: string;
  78558. /** Gets or sets default key button right padding */
  78559. defaultButtonPaddingRight: string;
  78560. /** Gets or sets default key button top padding */
  78561. defaultButtonPaddingTop: string;
  78562. /** Gets or sets default key button bottom padding */
  78563. defaultButtonPaddingBottom: string;
  78564. /** Gets or sets default key button foreground color */
  78565. defaultButtonColor: string;
  78566. /** Gets or sets default key button background color */
  78567. defaultButtonBackground: string;
  78568. /** Gets or sets shift button foreground color */
  78569. shiftButtonColor: string;
  78570. /** Gets or sets shift button thickness*/
  78571. selectedShiftThickness: number;
  78572. /** Gets shift key state */
  78573. shiftState: number;
  78574. protected _getTypeName(): string;
  78575. private _createKey;
  78576. /**
  78577. * Adds a new row of keys
  78578. * @param keys defines the list of keys to add
  78579. * @param propertySets defines the associated property sets
  78580. */
  78581. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  78582. /**
  78583. * Set the shift key to a specific state
  78584. * @param shiftState defines the new shift state
  78585. */
  78586. applyShiftState(shiftState: number): void;
  78587. private _currentlyConnectedInputText;
  78588. private _connectedInputTexts;
  78589. private _onKeyPressObserver;
  78590. /** Gets the input text control currently attached to the keyboard */
  78591. get connectedInputText(): BABYLON.Nullable<InputText>;
  78592. /**
  78593. * Connects the keyboard with an input text control
  78594. *
  78595. * @param input defines the target control
  78596. */
  78597. connect(input: InputText): void;
  78598. /**
  78599. * Disconnects the keyboard from connected InputText controls
  78600. *
  78601. * @param input optionally defines a target control, otherwise all are disconnected
  78602. */
  78603. disconnect(input?: InputText): void;
  78604. private _removeConnectedInputObservables;
  78605. /**
  78606. * Release all resources
  78607. */
  78608. dispose(): void;
  78609. /**
  78610. * Creates a new keyboard using a default layout
  78611. *
  78612. * @param name defines control name
  78613. * @returns a new VirtualKeyboard
  78614. */
  78615. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  78616. }
  78617. }
  78618. declare module BABYLON.GUI {
  78619. /**
  78620. * Class used to create input text control
  78621. */
  78622. export class InputText extends Control implements IFocusableControl {
  78623. name?: string | undefined;
  78624. private _text;
  78625. private _placeholderText;
  78626. private _background;
  78627. private _focusedBackground;
  78628. private _focusedColor;
  78629. private _placeholderColor;
  78630. private _thickness;
  78631. private _margin;
  78632. private _autoStretchWidth;
  78633. private _maxWidth;
  78634. private _isFocused;
  78635. private _blinkTimeout;
  78636. private _blinkIsEven;
  78637. private _cursorOffset;
  78638. private _scrollLeft;
  78639. private _textWidth;
  78640. private _clickedCoordinate;
  78641. private _deadKey;
  78642. private _addKey;
  78643. private _currentKey;
  78644. private _isTextHighlightOn;
  78645. private _textHighlightColor;
  78646. private _highligherOpacity;
  78647. private _highlightedText;
  78648. private _startHighlightIndex;
  78649. private _endHighlightIndex;
  78650. private _cursorIndex;
  78651. private _onFocusSelectAll;
  78652. private _isPointerDown;
  78653. private _onClipboardObserver;
  78654. private _onPointerDblTapObserver;
  78655. /** @hidden */
  78656. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  78657. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  78658. promptMessage: string;
  78659. /** Force disable prompt on mobile device */
  78660. disableMobilePrompt: boolean;
  78661. /** BABYLON.Observable raised when the text changes */
  78662. onTextChangedObservable: BABYLON.Observable<InputText>;
  78663. /** BABYLON.Observable raised just before an entered character is to be added */
  78664. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  78665. /** BABYLON.Observable raised when the control gets the focus */
  78666. onFocusObservable: BABYLON.Observable<InputText>;
  78667. /** BABYLON.Observable raised when the control loses the focus */
  78668. onBlurObservable: BABYLON.Observable<InputText>;
  78669. /**Observable raised when the text is highlighted */
  78670. onTextHighlightObservable: BABYLON.Observable<InputText>;
  78671. /**Observable raised when copy event is triggered */
  78672. onTextCopyObservable: BABYLON.Observable<InputText>;
  78673. /** BABYLON.Observable raised when cut event is triggered */
  78674. onTextCutObservable: BABYLON.Observable<InputText>;
  78675. /** BABYLON.Observable raised when paste event is triggered */
  78676. onTextPasteObservable: BABYLON.Observable<InputText>;
  78677. /** BABYLON.Observable raised when a key event was processed */
  78678. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  78679. /** Gets or sets the maximum width allowed by the control */
  78680. get maxWidth(): string | number;
  78681. /** Gets the maximum width allowed by the control in pixels */
  78682. get maxWidthInPixels(): number;
  78683. set maxWidth(value: string | number);
  78684. /** Gets or sets the text highlighter transparency; default: 0.4 */
  78685. get highligherOpacity(): number;
  78686. set highligherOpacity(value: number);
  78687. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  78688. get onFocusSelectAll(): boolean;
  78689. set onFocusSelectAll(value: boolean);
  78690. /** Gets or sets the text hightlight color */
  78691. get textHighlightColor(): string;
  78692. set textHighlightColor(value: string);
  78693. /** Gets or sets control margin */
  78694. get margin(): string;
  78695. /** Gets control margin in pixels */
  78696. get marginInPixels(): number;
  78697. set margin(value: string);
  78698. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  78699. get autoStretchWidth(): boolean;
  78700. set autoStretchWidth(value: boolean);
  78701. /** Gets or sets border thickness */
  78702. get thickness(): number;
  78703. set thickness(value: number);
  78704. /** Gets or sets the background color when focused */
  78705. get focusedBackground(): string;
  78706. set focusedBackground(value: string);
  78707. /** Gets or sets the background color when focused */
  78708. get focusedColor(): string;
  78709. set focusedColor(value: string);
  78710. /** Gets or sets the background color */
  78711. get background(): string;
  78712. set background(value: string);
  78713. /** Gets or sets the placeholder color */
  78714. get placeholderColor(): string;
  78715. set placeholderColor(value: string);
  78716. /** Gets or sets the text displayed when the control is empty */
  78717. get placeholderText(): string;
  78718. set placeholderText(value: string);
  78719. /** Gets or sets the dead key flag */
  78720. get deadKey(): boolean;
  78721. set deadKey(flag: boolean);
  78722. /** Gets or sets the highlight text */
  78723. get highlightedText(): string;
  78724. set highlightedText(text: string);
  78725. /** Gets or sets if the current key should be added */
  78726. get addKey(): boolean;
  78727. set addKey(flag: boolean);
  78728. /** Gets or sets the value of the current key being entered */
  78729. get currentKey(): string;
  78730. set currentKey(key: string);
  78731. /** Gets or sets the text displayed in the control */
  78732. get text(): string;
  78733. set text(value: string);
  78734. /** Gets or sets control width */
  78735. get width(): string | number;
  78736. set width(value: string | number);
  78737. /**
  78738. * Creates a new InputText
  78739. * @param name defines the control name
  78740. * @param text defines the text of the control
  78741. */
  78742. constructor(name?: string | undefined, text?: string);
  78743. /** @hidden */
  78744. onBlur(): void;
  78745. /** @hidden */
  78746. onFocus(): void;
  78747. protected _getTypeName(): string;
  78748. /**
  78749. * Function called to get the list of controls that should not steal the focus from this control
  78750. * @returns an array of controls
  78751. */
  78752. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  78753. /** @hidden */
  78754. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  78755. /** @hidden */
  78756. private _updateValueFromCursorIndex;
  78757. /** @hidden */
  78758. private _processDblClick;
  78759. /** @hidden */
  78760. private _selectAllText;
  78761. /**
  78762. * Handles the keyboard event
  78763. * @param evt Defines the KeyboardEvent
  78764. */
  78765. processKeyboard(evt: KeyboardEvent): void;
  78766. /** @hidden */
  78767. private _onCopyText;
  78768. /** @hidden */
  78769. private _onCutText;
  78770. /** @hidden */
  78771. private _onPasteText;
  78772. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78773. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78774. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  78775. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78776. protected _beforeRenderText(text: string): string;
  78777. dispose(): void;
  78778. }
  78779. }
  78780. declare module BABYLON.GUI {
  78781. /**
  78782. * Class used to create a 2D grid container
  78783. */
  78784. export class Grid extends Container {
  78785. name?: string | undefined;
  78786. private _rowDefinitions;
  78787. private _columnDefinitions;
  78788. private _cells;
  78789. private _childControls;
  78790. /**
  78791. * Gets the number of columns
  78792. */
  78793. get columnCount(): number;
  78794. /**
  78795. * Gets the number of rows
  78796. */
  78797. get rowCount(): number;
  78798. /** Gets the list of children */
  78799. get children(): Control[];
  78800. /** Gets the list of cells (e.g. the containers) */
  78801. get cells(): {
  78802. [key: string]: Container;
  78803. };
  78804. /**
  78805. * Gets the definition of a specific row
  78806. * @param index defines the index of the row
  78807. * @returns the row definition
  78808. */
  78809. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  78810. /**
  78811. * Gets the definition of a specific column
  78812. * @param index defines the index of the column
  78813. * @returns the column definition
  78814. */
  78815. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  78816. /**
  78817. * Adds a new row to the grid
  78818. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  78819. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  78820. * @returns the current grid
  78821. */
  78822. addRowDefinition(height: number, isPixel?: boolean): Grid;
  78823. /**
  78824. * Adds a new column to the grid
  78825. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  78826. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  78827. * @returns the current grid
  78828. */
  78829. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  78830. /**
  78831. * Update a row definition
  78832. * @param index defines the index of the row to update
  78833. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  78834. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  78835. * @returns the current grid
  78836. */
  78837. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  78838. /**
  78839. * Update a column definition
  78840. * @param index defines the index of the column to update
  78841. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  78842. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  78843. * @returns the current grid
  78844. */
  78845. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  78846. /**
  78847. * Gets the list of children stored in a specific cell
  78848. * @param row defines the row to check
  78849. * @param column defines the column to check
  78850. * @returns the list of controls
  78851. */
  78852. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  78853. /**
  78854. * Gets a string representing the child cell info (row x column)
  78855. * @param child defines the control to get info from
  78856. * @returns a string containing the child cell info (row x column)
  78857. */
  78858. getChildCellInfo(child: Control): string;
  78859. private _removeCell;
  78860. private _offsetCell;
  78861. /**
  78862. * Remove a column definition at specified index
  78863. * @param index defines the index of the column to remove
  78864. * @returns the current grid
  78865. */
  78866. removeColumnDefinition(index: number): Grid;
  78867. /**
  78868. * Remove a row definition at specified index
  78869. * @param index defines the index of the row to remove
  78870. * @returns the current grid
  78871. */
  78872. removeRowDefinition(index: number): Grid;
  78873. /**
  78874. * Adds a new control to the current grid
  78875. * @param control defines the control to add
  78876. * @param row defines the row where to add the control (0 by default)
  78877. * @param column defines the column where to add the control (0 by default)
  78878. * @returns the current grid
  78879. */
  78880. addControl(control: Control, row?: number, column?: number): Grid;
  78881. /**
  78882. * Removes a control from the current container
  78883. * @param control defines the control to remove
  78884. * @returns the current container
  78885. */
  78886. removeControl(control: Control): Container;
  78887. /**
  78888. * Creates a new Grid
  78889. * @param name defines control name
  78890. */
  78891. constructor(name?: string | undefined);
  78892. protected _getTypeName(): string;
  78893. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  78894. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78895. _flagDescendantsAsMatrixDirty(): void;
  78896. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  78897. /** Releases associated resources */
  78898. dispose(): void;
  78899. }
  78900. }
  78901. declare module BABYLON.GUI {
  78902. /** Class used to create color pickers */
  78903. export class ColorPicker extends Control {
  78904. name?: string | undefined;
  78905. private static _Epsilon;
  78906. private _colorWheelCanvas;
  78907. private _value;
  78908. private _tmpColor;
  78909. private _pointerStartedOnSquare;
  78910. private _pointerStartedOnWheel;
  78911. private _squareLeft;
  78912. private _squareTop;
  78913. private _squareSize;
  78914. private _h;
  78915. private _s;
  78916. private _v;
  78917. private _lastPointerDownID;
  78918. /**
  78919. * BABYLON.Observable raised when the value changes
  78920. */
  78921. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  78922. /** Gets or sets the color of the color picker */
  78923. get value(): BABYLON.Color3;
  78924. set value(value: BABYLON.Color3);
  78925. /**
  78926. * Gets or sets control width
  78927. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78928. */
  78929. get width(): string | number;
  78930. set width(value: string | number);
  78931. /**
  78932. * Gets or sets control height
  78933. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78934. */
  78935. get height(): string | number;
  78936. /** Gets or sets control height */
  78937. set height(value: string | number);
  78938. /** Gets or sets control size */
  78939. get size(): string | number;
  78940. set size(value: string | number);
  78941. /**
  78942. * Creates a new ColorPicker
  78943. * @param name defines the control name
  78944. */
  78945. constructor(name?: string | undefined);
  78946. protected _getTypeName(): string;
  78947. /** @hidden */
  78948. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78949. private _updateSquareProps;
  78950. private _drawGradientSquare;
  78951. private _drawCircle;
  78952. private _createColorWheelCanvas;
  78953. /** @hidden */
  78954. _draw(context: CanvasRenderingContext2D): void;
  78955. private _pointerIsDown;
  78956. private _updateValueFromPointer;
  78957. private _isPointOnSquare;
  78958. private _isPointOnWheel;
  78959. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78960. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  78961. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78962. _onCanvasBlur(): void;
  78963. /**
  78964. * This function expands the color picker by creating a color picker dialog with manual
  78965. * color value input and the ability to save colors into an array to be used later in
  78966. * subsequent launches of the dialogue.
  78967. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  78968. * @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.
  78969. * @returns picked color as a hex string and the saved colors array as hex strings.
  78970. */
  78971. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  78972. pickerWidth?: string;
  78973. pickerHeight?: string;
  78974. headerHeight?: string;
  78975. lastColor?: string;
  78976. swatchLimit?: number;
  78977. numSwatchesPerLine?: number;
  78978. savedColors?: Array<string>;
  78979. }): Promise<{
  78980. savedColors?: string[];
  78981. pickedColor: string;
  78982. }>;
  78983. }
  78984. }
  78985. declare module BABYLON.GUI {
  78986. /** Class used to create 2D ellipse containers */
  78987. export class Ellipse extends Container {
  78988. name?: string | undefined;
  78989. private _thickness;
  78990. /** Gets or sets border thickness */
  78991. get thickness(): number;
  78992. set thickness(value: number);
  78993. /**
  78994. * Creates a new Ellipse
  78995. * @param name defines the control name
  78996. */
  78997. constructor(name?: string | undefined);
  78998. protected _getTypeName(): string;
  78999. protected _localDraw(context: CanvasRenderingContext2D): void;
  79000. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79001. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  79002. }
  79003. }
  79004. declare module BABYLON.GUI {
  79005. /**
  79006. * Class used to create a password control
  79007. */
  79008. export class InputPassword extends InputText {
  79009. protected _beforeRenderText(text: string): string;
  79010. }
  79011. }
  79012. declare module BABYLON.GUI {
  79013. /** Class used to render 2D lines */
  79014. export class Line extends Control {
  79015. name?: string | undefined;
  79016. private _lineWidth;
  79017. private _x1;
  79018. private _y1;
  79019. private _x2;
  79020. private _y2;
  79021. private _dash;
  79022. private _connectedControl;
  79023. private _connectedControlDirtyObserver;
  79024. /** Gets or sets the dash pattern */
  79025. get dash(): Array<number>;
  79026. set dash(value: Array<number>);
  79027. /** Gets or sets the control connected with the line end */
  79028. get connectedControl(): Control;
  79029. set connectedControl(value: Control);
  79030. /** Gets or sets start coordinates on X axis */
  79031. get x1(): string | number;
  79032. set x1(value: string | number);
  79033. /** Gets or sets start coordinates on Y axis */
  79034. get y1(): string | number;
  79035. set y1(value: string | number);
  79036. /** Gets or sets end coordinates on X axis */
  79037. get x2(): string | number;
  79038. set x2(value: string | number);
  79039. /** Gets or sets end coordinates on Y axis */
  79040. get y2(): string | number;
  79041. set y2(value: string | number);
  79042. /** Gets or sets line width */
  79043. get lineWidth(): number;
  79044. set lineWidth(value: number);
  79045. /** Gets or sets horizontal alignment */
  79046. set horizontalAlignment(value: number);
  79047. /** Gets or sets vertical alignment */
  79048. set verticalAlignment(value: number);
  79049. private get _effectiveX2();
  79050. private get _effectiveY2();
  79051. /**
  79052. * Creates a new Line
  79053. * @param name defines the control name
  79054. */
  79055. constructor(name?: string | undefined);
  79056. protected _getTypeName(): string;
  79057. _draw(context: CanvasRenderingContext2D): void;
  79058. _measure(): void;
  79059. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79060. /**
  79061. * Move one end of the line given 3D cartesian coordinates.
  79062. * @param position Targeted world position
  79063. * @param scene BABYLON.Scene
  79064. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  79065. */
  79066. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  79067. /**
  79068. * Move one end of the line to a position in screen absolute space.
  79069. * @param projectedPosition Position in screen absolute space (X, Y)
  79070. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  79071. */
  79072. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  79073. }
  79074. }
  79075. declare module BABYLON.GUI {
  79076. /**
  79077. * Class used to store a point for a MultiLine object.
  79078. * The point can be pure 2D coordinates, a mesh or a control
  79079. */
  79080. export class MultiLinePoint {
  79081. private _multiLine;
  79082. private _x;
  79083. private _y;
  79084. private _control;
  79085. private _mesh;
  79086. private _controlObserver;
  79087. private _meshObserver;
  79088. /** @hidden */
  79089. _point: BABYLON.Vector2;
  79090. /**
  79091. * Creates a new MultiLinePoint
  79092. * @param multiLine defines the source MultiLine object
  79093. */
  79094. constructor(multiLine: MultiLine);
  79095. /** Gets or sets x coordinate */
  79096. get x(): string | number;
  79097. set x(value: string | number);
  79098. /** Gets or sets y coordinate */
  79099. get y(): string | number;
  79100. set y(value: string | number);
  79101. /** Gets or sets the control associated with this point */
  79102. get control(): BABYLON.Nullable<Control>;
  79103. set control(value: BABYLON.Nullable<Control>);
  79104. /** Gets or sets the mesh associated with this point */
  79105. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  79106. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  79107. /** Resets links */
  79108. resetLinks(): void;
  79109. /**
  79110. * Gets a translation vector
  79111. * @returns the translation vector
  79112. */
  79113. translate(): BABYLON.Vector2;
  79114. private _translatePoint;
  79115. /** Release associated resources */
  79116. dispose(): void;
  79117. }
  79118. }
  79119. declare module BABYLON.GUI {
  79120. /**
  79121. * Class used to create multi line control
  79122. */
  79123. export class MultiLine extends Control {
  79124. name?: string | undefined;
  79125. private _lineWidth;
  79126. private _dash;
  79127. private _points;
  79128. private _minX;
  79129. private _minY;
  79130. private _maxX;
  79131. private _maxY;
  79132. /**
  79133. * Creates a new MultiLine
  79134. * @param name defines the control name
  79135. */
  79136. constructor(name?: string | undefined);
  79137. /** Gets or sets dash pattern */
  79138. get dash(): Array<number>;
  79139. set dash(value: Array<number>);
  79140. /**
  79141. * Gets point stored at specified index
  79142. * @param index defines the index to look for
  79143. * @returns the requested point if found
  79144. */
  79145. getAt(index: number): MultiLinePoint;
  79146. /** Function called when a point is updated */
  79147. onPointUpdate: () => void;
  79148. /**
  79149. * Adds new points to the point collection
  79150. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  79151. * @returns the list of created MultiLinePoint
  79152. */
  79153. add(...items: (AbstractMesh | Control | {
  79154. x: string | number;
  79155. y: string | number;
  79156. })[]): MultiLinePoint[];
  79157. /**
  79158. * Adds a new point to the point collection
  79159. * @param item defines the item (mesh, control or 2d coordiantes) to add
  79160. * @returns the created MultiLinePoint
  79161. */
  79162. push(item?: (AbstractMesh | Control | {
  79163. x: string | number;
  79164. y: string | number;
  79165. })): MultiLinePoint;
  79166. /**
  79167. * Remove a specific value or point from the active point collection
  79168. * @param value defines the value or point to remove
  79169. */
  79170. remove(value: number | MultiLinePoint): void;
  79171. /**
  79172. * Resets this object to initial state (no point)
  79173. */
  79174. reset(): void;
  79175. /**
  79176. * Resets all links
  79177. */
  79178. resetLinks(): void;
  79179. /** Gets or sets line width */
  79180. get lineWidth(): number;
  79181. set lineWidth(value: number);
  79182. set horizontalAlignment(value: number);
  79183. set verticalAlignment(value: number);
  79184. protected _getTypeName(): string;
  79185. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79186. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79187. _measure(): void;
  79188. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79189. dispose(): void;
  79190. }
  79191. }
  79192. declare module BABYLON.GUI {
  79193. /**
  79194. * Class used to create radio button controls
  79195. */
  79196. export class RadioButton extends Control {
  79197. name?: string | undefined;
  79198. private _isChecked;
  79199. private _background;
  79200. private _checkSizeRatio;
  79201. private _thickness;
  79202. /** Gets or sets border thickness */
  79203. get thickness(): number;
  79204. set thickness(value: number);
  79205. /** Gets or sets group name */
  79206. group: string;
  79207. /** BABYLON.Observable raised when isChecked is changed */
  79208. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  79209. /** Gets or sets a value indicating the ratio between overall size and check size */
  79210. get checkSizeRatio(): number;
  79211. set checkSizeRatio(value: number);
  79212. /** Gets or sets background color */
  79213. get background(): string;
  79214. set background(value: string);
  79215. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  79216. get isChecked(): boolean;
  79217. set isChecked(value: boolean);
  79218. /**
  79219. * Creates a new RadioButton
  79220. * @param name defines the control name
  79221. */
  79222. constructor(name?: string | undefined);
  79223. protected _getTypeName(): string;
  79224. _draw(context: CanvasRenderingContext2D): void;
  79225. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  79226. /**
  79227. * Utility function to easily create a radio button with a header
  79228. * @param title defines the label to use for the header
  79229. * @param group defines the group to use for the radio button
  79230. * @param isChecked defines the initial state of the radio button
  79231. * @param onValueChanged defines the callback to call when value changes
  79232. * @returns a StackPanel containing the radio button and a textBlock
  79233. */
  79234. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  79235. }
  79236. }
  79237. declare module BABYLON.GUI {
  79238. /**
  79239. * Class used to create slider controls
  79240. */
  79241. export class BaseSlider extends Control {
  79242. name?: string | undefined;
  79243. protected _thumbWidth: ValueAndUnit;
  79244. private _minimum;
  79245. private _maximum;
  79246. private _value;
  79247. private _isVertical;
  79248. protected _barOffset: ValueAndUnit;
  79249. private _isThumbClamped;
  79250. protected _displayThumb: boolean;
  79251. private _step;
  79252. private _lastPointerDownID;
  79253. protected _effectiveBarOffset: number;
  79254. protected _renderLeft: number;
  79255. protected _renderTop: number;
  79256. protected _renderWidth: number;
  79257. protected _renderHeight: number;
  79258. protected _backgroundBoxLength: number;
  79259. protected _backgroundBoxThickness: number;
  79260. protected _effectiveThumbThickness: number;
  79261. /** BABYLON.Observable raised when the sldier value changes */
  79262. onValueChangedObservable: BABYLON.Observable<number>;
  79263. /** Gets or sets a boolean indicating if the thumb must be rendered */
  79264. get displayThumb(): boolean;
  79265. set displayThumb(value: boolean);
  79266. /** Gets or sets a step to apply to values (0 by default) */
  79267. get step(): number;
  79268. set step(value: number);
  79269. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  79270. get barOffset(): string | number;
  79271. /** Gets main bar offset in pixels*/
  79272. get barOffsetInPixels(): number;
  79273. set barOffset(value: string | number);
  79274. /** Gets or sets thumb width */
  79275. get thumbWidth(): string | number;
  79276. /** Gets thumb width in pixels */
  79277. get thumbWidthInPixels(): number;
  79278. set thumbWidth(value: string | number);
  79279. /** Gets or sets minimum value */
  79280. get minimum(): number;
  79281. set minimum(value: number);
  79282. /** Gets or sets maximum value */
  79283. get maximum(): number;
  79284. set maximum(value: number);
  79285. /** Gets or sets current value */
  79286. get value(): number;
  79287. set value(value: number);
  79288. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  79289. get isVertical(): boolean;
  79290. set isVertical(value: boolean);
  79291. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  79292. get isThumbClamped(): boolean;
  79293. set isThumbClamped(value: boolean);
  79294. /**
  79295. * Creates a new BaseSlider
  79296. * @param name defines the control name
  79297. */
  79298. constructor(name?: string | undefined);
  79299. protected _getTypeName(): string;
  79300. protected _getThumbPosition(): number;
  79301. protected _getThumbThickness(type: string): number;
  79302. protected _prepareRenderingData(type: string): void;
  79303. private _pointerIsDown;
  79304. /** @hidden */
  79305. protected _updateValueFromPointer(x: number, y: number): void;
  79306. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  79307. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  79308. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  79309. _onCanvasBlur(): void;
  79310. }
  79311. }
  79312. declare module BABYLON.GUI {
  79313. /**
  79314. * Class used to create slider controls
  79315. */
  79316. export class Slider extends BaseSlider {
  79317. name?: string | undefined;
  79318. private _background;
  79319. private _borderColor;
  79320. private _thumbColor;
  79321. private _isThumbCircle;
  79322. protected _displayValueBar: boolean;
  79323. /** Gets or sets a boolean indicating if the value bar must be rendered */
  79324. get displayValueBar(): boolean;
  79325. set displayValueBar(value: boolean);
  79326. /** Gets or sets border color */
  79327. get borderColor(): string;
  79328. set borderColor(value: string);
  79329. /** Gets or sets background color */
  79330. get background(): string;
  79331. set background(value: string);
  79332. /** Gets or sets thumb's color */
  79333. get thumbColor(): string;
  79334. set thumbColor(value: string);
  79335. /** Gets or sets a boolean indicating if the thumb should be round or square */
  79336. get isThumbCircle(): boolean;
  79337. set isThumbCircle(value: boolean);
  79338. /**
  79339. * Creates a new Slider
  79340. * @param name defines the control name
  79341. */
  79342. constructor(name?: string | undefined);
  79343. protected _getTypeName(): string;
  79344. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79345. }
  79346. }
  79347. declare module BABYLON.GUI {
  79348. /** Class used to create a RadioGroup
  79349. * which contains groups of radio buttons
  79350. */
  79351. export class SelectorGroup {
  79352. /** name of SelectorGroup */
  79353. name: string;
  79354. private _groupPanel;
  79355. private _selectors;
  79356. private _groupHeader;
  79357. /**
  79358. * Creates a new SelectorGroup
  79359. * @param name of group, used as a group heading
  79360. */
  79361. constructor(
  79362. /** name of SelectorGroup */
  79363. name: string);
  79364. /** Gets the groupPanel of the SelectorGroup */
  79365. get groupPanel(): StackPanel;
  79366. /** Gets the selectors array */
  79367. get selectors(): StackPanel[];
  79368. /** Gets and sets the group header */
  79369. get header(): string;
  79370. set header(label: string);
  79371. /** @hidden */
  79372. private _addGroupHeader;
  79373. /** @hidden*/
  79374. _getSelector(selectorNb: number): StackPanel | undefined;
  79375. /** Removes the selector at the given position
  79376. * @param selectorNb the position of the selector within the group
  79377. */
  79378. removeSelector(selectorNb: number): void;
  79379. }
  79380. /** Class used to create a CheckboxGroup
  79381. * which contains groups of checkbox buttons
  79382. */
  79383. export class CheckboxGroup extends SelectorGroup {
  79384. /** Adds a checkbox as a control
  79385. * @param text is the label for the selector
  79386. * @param func is the function called when the Selector is checked
  79387. * @param checked is true when Selector is checked
  79388. */
  79389. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  79390. /** @hidden */
  79391. _setSelectorLabel(selectorNb: number, label: string): void;
  79392. /** @hidden */
  79393. _setSelectorLabelColor(selectorNb: number, color: string): void;
  79394. /** @hidden */
  79395. _setSelectorButtonColor(selectorNb: number, color: string): void;
  79396. /** @hidden */
  79397. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  79398. }
  79399. /** Class used to create a RadioGroup
  79400. * which contains groups of radio buttons
  79401. */
  79402. export class RadioGroup extends SelectorGroup {
  79403. private _selectNb;
  79404. /** Adds a radio button as a control
  79405. * @param label is the label for the selector
  79406. * @param func is the function called when the Selector is checked
  79407. * @param checked is true when Selector is checked
  79408. */
  79409. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  79410. /** @hidden */
  79411. _setSelectorLabel(selectorNb: number, label: string): void;
  79412. /** @hidden */
  79413. _setSelectorLabelColor(selectorNb: number, color: string): void;
  79414. /** @hidden */
  79415. _setSelectorButtonColor(selectorNb: number, color: string): void;
  79416. /** @hidden */
  79417. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  79418. }
  79419. /** Class used to create a SliderGroup
  79420. * which contains groups of slider buttons
  79421. */
  79422. export class SliderGroup extends SelectorGroup {
  79423. /**
  79424. * Adds a slider to the SelectorGroup
  79425. * @param label is the label for the SliderBar
  79426. * @param func is the function called when the Slider moves
  79427. * @param unit is a string describing the units used, eg degrees or metres
  79428. * @param min is the minimum value for the Slider
  79429. * @param max is the maximum value for the Slider
  79430. * @param value is the start value for the Slider between min and max
  79431. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  79432. */
  79433. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  79434. /** @hidden */
  79435. _setSelectorLabel(selectorNb: number, label: string): void;
  79436. /** @hidden */
  79437. _setSelectorLabelColor(selectorNb: number, color: string): void;
  79438. /** @hidden */
  79439. _setSelectorButtonColor(selectorNb: number, color: string): void;
  79440. /** @hidden */
  79441. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  79442. }
  79443. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  79444. * @see https://doc.babylonjs.com/how_to/selector
  79445. */
  79446. export class SelectionPanel extends Rectangle {
  79447. /** name of SelectionPanel */
  79448. name: string;
  79449. /** an array of SelectionGroups */
  79450. groups: SelectorGroup[];
  79451. private _panel;
  79452. private _buttonColor;
  79453. private _buttonBackground;
  79454. private _headerColor;
  79455. private _barColor;
  79456. private _barHeight;
  79457. private _spacerHeight;
  79458. private _labelColor;
  79459. private _groups;
  79460. private _bars;
  79461. /**
  79462. * Creates a new SelectionPanel
  79463. * @param name of SelectionPanel
  79464. * @param groups is an array of SelectionGroups
  79465. */
  79466. constructor(
  79467. /** name of SelectionPanel */
  79468. name: string,
  79469. /** an array of SelectionGroups */
  79470. groups?: SelectorGroup[]);
  79471. protected _getTypeName(): string;
  79472. /** Gets or sets the headerColor */
  79473. get headerColor(): string;
  79474. set headerColor(color: string);
  79475. private _setHeaderColor;
  79476. /** Gets or sets the button color */
  79477. get buttonColor(): string;
  79478. set buttonColor(color: string);
  79479. private _setbuttonColor;
  79480. /** Gets or sets the label color */
  79481. get labelColor(): string;
  79482. set labelColor(color: string);
  79483. private _setLabelColor;
  79484. /** Gets or sets the button background */
  79485. get buttonBackground(): string;
  79486. set buttonBackground(color: string);
  79487. private _setButtonBackground;
  79488. /** Gets or sets the color of separator bar */
  79489. get barColor(): string;
  79490. set barColor(color: string);
  79491. private _setBarColor;
  79492. /** Gets or sets the height of separator bar */
  79493. get barHeight(): string;
  79494. set barHeight(value: string);
  79495. private _setBarHeight;
  79496. /** Gets or sets the height of spacers*/
  79497. get spacerHeight(): string;
  79498. set spacerHeight(value: string);
  79499. private _setSpacerHeight;
  79500. /** Adds a bar between groups */
  79501. private _addSpacer;
  79502. /** Add a group to the selection panel
  79503. * @param group is the selector group to add
  79504. */
  79505. addGroup(group: SelectorGroup): void;
  79506. /** Remove the group from the given position
  79507. * @param groupNb is the position of the group in the list
  79508. */
  79509. removeGroup(groupNb: number): void;
  79510. /** Change a group header label
  79511. * @param label is the new group header label
  79512. * @param groupNb is the number of the group to relabel
  79513. * */
  79514. setHeaderName(label: string, groupNb: number): void;
  79515. /** Change selector label to the one given
  79516. * @param label is the new selector label
  79517. * @param groupNb is the number of the groupcontaining the selector
  79518. * @param selectorNb is the number of the selector within a group to relabel
  79519. * */
  79520. relabel(label: string, groupNb: number, selectorNb: number): void;
  79521. /** For a given group position remove the selector at the given position
  79522. * @param groupNb is the number of the group to remove the selector from
  79523. * @param selectorNb is the number of the selector within the group
  79524. */
  79525. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  79526. /** For a given group position of correct type add a checkbox button
  79527. * @param groupNb is the number of the group to remove the selector from
  79528. * @param label is the label for the selector
  79529. * @param func is the function called when the Selector is checked
  79530. * @param checked is true when Selector is checked
  79531. */
  79532. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  79533. /** For a given group position of correct type add a radio button
  79534. * @param groupNb is the number of the group to remove the selector from
  79535. * @param label is the label for the selector
  79536. * @param func is the function called when the Selector is checked
  79537. * @param checked is true when Selector is checked
  79538. */
  79539. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  79540. /**
  79541. * For a given slider group add a slider
  79542. * @param groupNb is the number of the group to add the slider to
  79543. * @param label is the label for the Slider
  79544. * @param func is the function called when the Slider moves
  79545. * @param unit is a string describing the units used, eg degrees or metres
  79546. * @param min is the minimum value for the Slider
  79547. * @param max is the maximum value for the Slider
  79548. * @param value is the start value for the Slider between min and max
  79549. * @param onVal is the function used to format the value displayed, eg radians to degrees
  79550. */
  79551. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  79552. }
  79553. }
  79554. declare module BABYLON.GUI {
  79555. /**
  79556. * Class used to hold a the container for ScrollViewer
  79557. * @hidden
  79558. */
  79559. export class _ScrollViewerWindow extends Container {
  79560. parentClientWidth: number;
  79561. parentClientHeight: number;
  79562. private _freezeControls;
  79563. private _parentMeasure;
  79564. private _oldLeft;
  79565. private _oldTop;
  79566. get freezeControls(): boolean;
  79567. set freezeControls(value: boolean);
  79568. private _bucketWidth;
  79569. private _bucketHeight;
  79570. private _buckets;
  79571. private _bucketLen;
  79572. get bucketWidth(): number;
  79573. get bucketHeight(): number;
  79574. setBucketSizes(width: number, height: number): void;
  79575. private _useBuckets;
  79576. private _makeBuckets;
  79577. private _dispatchInBuckets;
  79578. private _updateMeasures;
  79579. private _updateChildrenMeasures;
  79580. private _restoreMeasures;
  79581. /**
  79582. * Creates a new ScrollViewerWindow
  79583. * @param name of ScrollViewerWindow
  79584. */
  79585. constructor(name?: string);
  79586. protected _getTypeName(): string;
  79587. /** @hidden */
  79588. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79589. /** @hidden */
  79590. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  79591. private _scrollChildren;
  79592. private _scrollChildrenWithBuckets;
  79593. /** @hidden */
  79594. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  79595. protected _postMeasure(): void;
  79596. }
  79597. }
  79598. declare module BABYLON.GUI {
  79599. /**
  79600. * Class used to create slider controls
  79601. */
  79602. export class ScrollBar extends BaseSlider {
  79603. name?: string | undefined;
  79604. private _background;
  79605. private _borderColor;
  79606. private _tempMeasure;
  79607. /** Gets or sets border color */
  79608. get borderColor(): string;
  79609. set borderColor(value: string);
  79610. /** Gets or sets background color */
  79611. get background(): string;
  79612. set background(value: string);
  79613. /**
  79614. * Creates a new Slider
  79615. * @param name defines the control name
  79616. */
  79617. constructor(name?: string | undefined);
  79618. protected _getTypeName(): string;
  79619. protected _getThumbThickness(): number;
  79620. _draw(context: CanvasRenderingContext2D): void;
  79621. private _first;
  79622. private _originX;
  79623. private _originY;
  79624. /** @hidden */
  79625. protected _updateValueFromPointer(x: number, y: number): void;
  79626. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  79627. }
  79628. }
  79629. declare module BABYLON.GUI {
  79630. /**
  79631. * Class used to create slider controls
  79632. */
  79633. export class ImageScrollBar extends BaseSlider {
  79634. name?: string | undefined;
  79635. private _backgroundBaseImage;
  79636. private _backgroundImage;
  79637. private _thumbImage;
  79638. private _thumbBaseImage;
  79639. private _thumbLength;
  79640. private _thumbHeight;
  79641. private _barImageHeight;
  79642. private _tempMeasure;
  79643. /** Number of 90° rotation to apply on the images when in vertical mode */
  79644. num90RotationInVerticalMode: number;
  79645. /**
  79646. * Gets or sets the image used to render the background for horizontal bar
  79647. */
  79648. get backgroundImage(): Image;
  79649. set backgroundImage(value: Image);
  79650. /**
  79651. * Gets or sets the image used to render the thumb
  79652. */
  79653. get thumbImage(): Image;
  79654. set thumbImage(value: Image);
  79655. /**
  79656. * Gets or sets the length of the thumb
  79657. */
  79658. get thumbLength(): number;
  79659. set thumbLength(value: number);
  79660. /**
  79661. * Gets or sets the height of the thumb
  79662. */
  79663. get thumbHeight(): number;
  79664. set thumbHeight(value: number);
  79665. /**
  79666. * Gets or sets the height of the bar image
  79667. */
  79668. get barImageHeight(): number;
  79669. set barImageHeight(value: number);
  79670. /**
  79671. * Creates a new ImageScrollBar
  79672. * @param name defines the control name
  79673. */
  79674. constructor(name?: string | undefined);
  79675. protected _getTypeName(): string;
  79676. protected _getThumbThickness(): number;
  79677. _draw(context: CanvasRenderingContext2D): void;
  79678. private _first;
  79679. private _originX;
  79680. private _originY;
  79681. /** @hidden */
  79682. protected _updateValueFromPointer(x: number, y: number): void;
  79683. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  79684. }
  79685. }
  79686. declare module BABYLON.GUI {
  79687. /**
  79688. * Class used to hold a viewer window and sliders in a grid
  79689. */
  79690. export class ScrollViewer extends Rectangle {
  79691. private _grid;
  79692. private _horizontalBarSpace;
  79693. private _verticalBarSpace;
  79694. private _dragSpace;
  79695. private _horizontalBar;
  79696. private _verticalBar;
  79697. private _barColor;
  79698. private _barBackground;
  79699. private _barImage;
  79700. private _horizontalBarImage;
  79701. private _verticalBarImage;
  79702. private _barBackgroundImage;
  79703. private _horizontalBarBackgroundImage;
  79704. private _verticalBarBackgroundImage;
  79705. private _barSize;
  79706. private _window;
  79707. private _pointerIsOver;
  79708. private _wheelPrecision;
  79709. private _onWheelObserver;
  79710. private _clientWidth;
  79711. private _clientHeight;
  79712. private _useImageBar;
  79713. private _thumbLength;
  79714. private _thumbHeight;
  79715. private _barImageHeight;
  79716. private _horizontalBarImageHeight;
  79717. private _verticalBarImageHeight;
  79718. private _oldWindowContentsWidth;
  79719. private _oldWindowContentsHeight;
  79720. /**
  79721. * Gets the horizontal scrollbar
  79722. */
  79723. get horizontalBar(): ScrollBar | ImageScrollBar;
  79724. /**
  79725. * Gets the vertical scrollbar
  79726. */
  79727. get verticalBar(): ScrollBar | ImageScrollBar;
  79728. /**
  79729. * Adds a new control to the current container
  79730. * @param control defines the control to add
  79731. * @returns the current container
  79732. */
  79733. addControl(control: BABYLON.Nullable<Control>): Container;
  79734. /**
  79735. * Removes a control from the current container
  79736. * @param control defines the control to remove
  79737. * @returns the current container
  79738. */
  79739. removeControl(control: Control): Container;
  79740. /** Gets the list of children */
  79741. get children(): Control[];
  79742. _flagDescendantsAsMatrixDirty(): void;
  79743. /**
  79744. * Freezes or unfreezes the controls in the window.
  79745. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  79746. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  79747. */
  79748. get freezeControls(): boolean;
  79749. set freezeControls(value: boolean);
  79750. /** Gets the bucket width */
  79751. get bucketWidth(): number;
  79752. /** Gets the bucket height */
  79753. get bucketHeight(): number;
  79754. /**
  79755. * Sets the bucket sizes.
  79756. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  79757. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  79758. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  79759. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  79760. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  79761. * used), that's why it is not enabled by default.
  79762. * @param width width of the bucket
  79763. * @param height height of the bucket
  79764. */
  79765. setBucketSizes(width: number, height: number): void;
  79766. private _forceHorizontalBar;
  79767. private _forceVerticalBar;
  79768. /**
  79769. * Forces the horizontal scroll bar to be displayed
  79770. */
  79771. get forceHorizontalBar(): boolean;
  79772. set forceHorizontalBar(value: boolean);
  79773. /**
  79774. * Forces the vertical scroll bar to be displayed
  79775. */
  79776. get forceVerticalBar(): boolean;
  79777. set forceVerticalBar(value: boolean);
  79778. /**
  79779. * Creates a new ScrollViewer
  79780. * @param name of ScrollViewer
  79781. */
  79782. constructor(name?: string, isImageBased?: boolean);
  79783. /** Reset the scroll viewer window to initial size */
  79784. resetWindow(): void;
  79785. protected _getTypeName(): string;
  79786. private _buildClientSizes;
  79787. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79788. protected _postMeasure(): void;
  79789. /**
  79790. * Gets or sets the mouse wheel precision
  79791. * from 0 to 1 with a default value of 0.05
  79792. * */
  79793. get wheelPrecision(): number;
  79794. set wheelPrecision(value: number);
  79795. /** Gets or sets the scroll bar container background color */
  79796. get scrollBackground(): string;
  79797. set scrollBackground(color: string);
  79798. /** Gets or sets the bar color */
  79799. get barColor(): string;
  79800. set barColor(color: string);
  79801. /** Gets or sets the bar image */
  79802. get thumbImage(): Image;
  79803. set thumbImage(value: Image);
  79804. /** Gets or sets the horizontal bar image */
  79805. get horizontalThumbImage(): Image;
  79806. set horizontalThumbImage(value: Image);
  79807. /** Gets or sets the vertical bar image */
  79808. get verticalThumbImage(): Image;
  79809. set verticalThumbImage(value: Image);
  79810. /** Gets or sets the size of the bar */
  79811. get barSize(): number;
  79812. set barSize(value: number);
  79813. /** Gets or sets the length of the thumb */
  79814. get thumbLength(): number;
  79815. set thumbLength(value: number);
  79816. /** Gets or sets the height of the thumb */
  79817. get thumbHeight(): number;
  79818. set thumbHeight(value: number);
  79819. /** Gets or sets the height of the bar image */
  79820. get barImageHeight(): number;
  79821. set barImageHeight(value: number);
  79822. /** Gets or sets the height of the horizontal bar image */
  79823. get horizontalBarImageHeight(): number;
  79824. set horizontalBarImageHeight(value: number);
  79825. /** Gets or sets the height of the vertical bar image */
  79826. get verticalBarImageHeight(): number;
  79827. set verticalBarImageHeight(value: number);
  79828. /** Gets or sets the bar background */
  79829. get barBackground(): string;
  79830. set barBackground(color: string);
  79831. /** Gets or sets the bar background image */
  79832. get barImage(): Image;
  79833. set barImage(value: Image);
  79834. /** Gets or sets the horizontal bar background image */
  79835. get horizontalBarImage(): Image;
  79836. set horizontalBarImage(value: Image);
  79837. /** Gets or sets the vertical bar background image */
  79838. get verticalBarImage(): Image;
  79839. set verticalBarImage(value: Image);
  79840. private _setWindowPosition;
  79841. /** @hidden */
  79842. private _updateScroller;
  79843. _link(host: AdvancedDynamicTexture): void;
  79844. /** @hidden */
  79845. private _addBar;
  79846. /** @hidden */
  79847. private _attachWheel;
  79848. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  79849. /** Releases associated resources */
  79850. dispose(): void;
  79851. }
  79852. }
  79853. declare module BABYLON.GUI {
  79854. /** Class used to render a grid */
  79855. export class DisplayGrid extends Control {
  79856. name?: string | undefined;
  79857. private _cellWidth;
  79858. private _cellHeight;
  79859. private _minorLineTickness;
  79860. private _minorLineColor;
  79861. private _majorLineTickness;
  79862. private _majorLineColor;
  79863. private _majorLineFrequency;
  79864. private _background;
  79865. private _displayMajorLines;
  79866. private _displayMinorLines;
  79867. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  79868. get displayMinorLines(): boolean;
  79869. set displayMinorLines(value: boolean);
  79870. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  79871. get displayMajorLines(): boolean;
  79872. set displayMajorLines(value: boolean);
  79873. /** Gets or sets background color (Black by default) */
  79874. get background(): string;
  79875. set background(value: string);
  79876. /** Gets or sets the width of each cell (20 by default) */
  79877. get cellWidth(): number;
  79878. set cellWidth(value: number);
  79879. /** Gets or sets the height of each cell (20 by default) */
  79880. get cellHeight(): number;
  79881. set cellHeight(value: number);
  79882. /** Gets or sets the tickness of minor lines (1 by default) */
  79883. get minorLineTickness(): number;
  79884. set minorLineTickness(value: number);
  79885. /** Gets or sets the color of minor lines (DarkGray by default) */
  79886. get minorLineColor(): string;
  79887. set minorLineColor(value: string);
  79888. /** Gets or sets the tickness of major lines (2 by default) */
  79889. get majorLineTickness(): number;
  79890. set majorLineTickness(value: number);
  79891. /** Gets or sets the color of major lines (White by default) */
  79892. get majorLineColor(): string;
  79893. set majorLineColor(value: string);
  79894. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  79895. get majorLineFrequency(): number;
  79896. set majorLineFrequency(value: number);
  79897. /**
  79898. * Creates a new GridDisplayRectangle
  79899. * @param name defines the control name
  79900. */
  79901. constructor(name?: string | undefined);
  79902. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79903. protected _getTypeName(): string;
  79904. }
  79905. }
  79906. declare module BABYLON.GUI {
  79907. /**
  79908. * Class used to create slider controls based on images
  79909. */
  79910. export class ImageBasedSlider extends BaseSlider {
  79911. name?: string | undefined;
  79912. private _backgroundImage;
  79913. private _thumbImage;
  79914. private _valueBarImage;
  79915. private _tempMeasure;
  79916. get displayThumb(): boolean;
  79917. set displayThumb(value: boolean);
  79918. /**
  79919. * Gets or sets the image used to render the background
  79920. */
  79921. get backgroundImage(): Image;
  79922. set backgroundImage(value: Image);
  79923. /**
  79924. * Gets or sets the image used to render the value bar
  79925. */
  79926. get valueBarImage(): Image;
  79927. set valueBarImage(value: Image);
  79928. /**
  79929. * Gets or sets the image used to render the thumb
  79930. */
  79931. get thumbImage(): Image;
  79932. set thumbImage(value: Image);
  79933. /**
  79934. * Creates a new ImageBasedSlider
  79935. * @param name defines the control name
  79936. */
  79937. constructor(name?: string | undefined);
  79938. protected _getTypeName(): string;
  79939. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79940. }
  79941. }
  79942. declare module BABYLON.GUI {
  79943. /**
  79944. * Forcing an export so that this code will execute
  79945. * @hidden
  79946. */
  79947. const name = "Statics";
  79948. }
  79949. declare module BABYLON.GUI {
  79950. /**
  79951. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  79952. */
  79953. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  79954. /**
  79955. * Define the instrumented AdvancedDynamicTexture.
  79956. */
  79957. texture: AdvancedDynamicTexture;
  79958. private _captureRenderTime;
  79959. private _renderTime;
  79960. private _captureLayoutTime;
  79961. private _layoutTime;
  79962. private _onBeginRenderObserver;
  79963. private _onEndRenderObserver;
  79964. private _onBeginLayoutObserver;
  79965. private _onEndLayoutObserver;
  79966. /**
  79967. * Gets the perf counter used to capture render time
  79968. */
  79969. get renderTimeCounter(): BABYLON.PerfCounter;
  79970. /**
  79971. * Gets the perf counter used to capture layout time
  79972. */
  79973. get layoutTimeCounter(): BABYLON.PerfCounter;
  79974. /**
  79975. * Enable or disable the render time capture
  79976. */
  79977. get captureRenderTime(): boolean;
  79978. set captureRenderTime(value: boolean);
  79979. /**
  79980. * Enable or disable the layout time capture
  79981. */
  79982. get captureLayoutTime(): boolean;
  79983. set captureLayoutTime(value: boolean);
  79984. /**
  79985. * Instantiates a new advanced dynamic texture instrumentation.
  79986. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  79987. * @param texture Defines the AdvancedDynamicTexture to instrument
  79988. */
  79989. constructor(
  79990. /**
  79991. * Define the instrumented AdvancedDynamicTexture.
  79992. */
  79993. texture: AdvancedDynamicTexture);
  79994. /**
  79995. * Dispose and release associated resources.
  79996. */
  79997. dispose(): void;
  79998. }
  79999. }
  80000. declare module BABYLON.GUI {
  80001. /**
  80002. * Class used to load GUI via XML.
  80003. */
  80004. export class XmlLoader {
  80005. private _nodes;
  80006. private _nodeTypes;
  80007. private _isLoaded;
  80008. private _objectAttributes;
  80009. private _parentClass;
  80010. /**
  80011. * Create a new xml loader
  80012. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  80013. */
  80014. constructor(parentClass?: null);
  80015. private _getChainElement;
  80016. private _getClassAttribute;
  80017. private _createGuiElement;
  80018. private _parseGrid;
  80019. private _parseElement;
  80020. private _prepareSourceElement;
  80021. private _parseElementsFromSource;
  80022. private _parseXml;
  80023. /**
  80024. * Gets if the loading has finished.
  80025. * @returns whether the loading has finished or not
  80026. */
  80027. isLoaded(): boolean;
  80028. /**
  80029. * Gets a loaded node / control by id.
  80030. * @param id the Controls id set in the xml
  80031. * @returns element of type Control
  80032. */
  80033. getNodeById(id: string): any;
  80034. /**
  80035. * Gets all loaded nodes / controls
  80036. * @returns Array of controls
  80037. */
  80038. getNodes(): any;
  80039. /**
  80040. * Initiates the xml layout loading
  80041. * @param xmlFile defines the xml layout to load
  80042. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  80043. * @param callback defines the callback called on layout load.
  80044. */
  80045. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  80046. }
  80047. }
  80048. declare module BABYLON.GUI {
  80049. /**
  80050. * Class used to create containers for controls
  80051. */
  80052. export class Container3D extends Control3D {
  80053. private _blockLayout;
  80054. /**
  80055. * Gets the list of child controls
  80056. */
  80057. protected _children: Control3D[];
  80058. /**
  80059. * Gets the list of child controls
  80060. */
  80061. get children(): Array<Control3D>;
  80062. /**
  80063. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  80064. * This is helpful to optimize layout operation when adding multiple children in a row
  80065. */
  80066. get blockLayout(): boolean;
  80067. set blockLayout(value: boolean);
  80068. /**
  80069. * Creates a new container
  80070. * @param name defines the container name
  80071. */
  80072. constructor(name?: string);
  80073. /**
  80074. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  80075. * @returns the current container
  80076. */
  80077. updateLayout(): Container3D;
  80078. /**
  80079. * Gets a boolean indicating if the given control is in the children of this control
  80080. * @param control defines the control to check
  80081. * @returns true if the control is in the child list
  80082. */
  80083. containsControl(control: Control3D): boolean;
  80084. /**
  80085. * Adds a control to the children of this control
  80086. * @param control defines the control to add
  80087. * @returns the current container
  80088. */
  80089. addControl(control: Control3D): Container3D;
  80090. /**
  80091. * This function will be called everytime a new control is added
  80092. */
  80093. protected _arrangeChildren(): void;
  80094. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  80095. /**
  80096. * Removes a control from the children of this control
  80097. * @param control defines the control to remove
  80098. * @returns the current container
  80099. */
  80100. removeControl(control: Control3D): Container3D;
  80101. protected _getTypeName(): string;
  80102. /**
  80103. * Releases all associated resources
  80104. */
  80105. dispose(): void;
  80106. /** Control rotation will remain unchanged */
  80107. static readonly UNSET_ORIENTATION: number;
  80108. /** Control will rotate to make it look at sphere central axis */
  80109. static readonly FACEORIGIN_ORIENTATION: number;
  80110. /** Control will rotate to make it look back at sphere central axis */
  80111. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  80112. /** Control will rotate to look at z axis (0, 0, 1) */
  80113. static readonly FACEFORWARD_ORIENTATION: number;
  80114. /** Control will rotate to look at negative z axis (0, 0, -1) */
  80115. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  80116. }
  80117. }
  80118. declare module BABYLON.GUI {
  80119. /**
  80120. * Class used to manage 3D user interface
  80121. * @see https://doc.babylonjs.com/how_to/gui3d
  80122. */
  80123. export class GUI3DManager implements BABYLON.IDisposable {
  80124. private _scene;
  80125. private _sceneDisposeObserver;
  80126. private _utilityLayer;
  80127. private _rootContainer;
  80128. private _pointerObserver;
  80129. private _pointerOutObserver;
  80130. /** @hidden */
  80131. _lastPickedControl: Control3D;
  80132. /** @hidden */
  80133. _lastControlOver: {
  80134. [pointerId: number]: Control3D;
  80135. };
  80136. /** @hidden */
  80137. _lastControlDown: {
  80138. [pointerId: number]: Control3D;
  80139. };
  80140. /**
  80141. * BABYLON.Observable raised when the point picked by the pointer events changed
  80142. */
  80143. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  80144. /** @hidden */
  80145. _sharedMaterials: {
  80146. [key: string]: BABYLON.Material;
  80147. };
  80148. /** Gets the hosting scene */
  80149. get scene(): BABYLON.Scene;
  80150. /** Gets associated utility layer */
  80151. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  80152. /**
  80153. * Creates a new GUI3DManager
  80154. * @param scene
  80155. */
  80156. constructor(scene?: BABYLON.Scene);
  80157. private _handlePointerOut;
  80158. private _doPicking;
  80159. /**
  80160. * Gets the root container
  80161. */
  80162. get rootContainer(): Container3D;
  80163. /**
  80164. * Gets a boolean indicating if the given control is in the root child list
  80165. * @param control defines the control to check
  80166. * @returns true if the control is in the root child list
  80167. */
  80168. containsControl(control: Control3D): boolean;
  80169. /**
  80170. * Adds a control to the root child list
  80171. * @param control defines the control to add
  80172. * @returns the current manager
  80173. */
  80174. addControl(control: Control3D): GUI3DManager;
  80175. /**
  80176. * Removes a control from the root child list
  80177. * @param control defines the control to remove
  80178. * @returns the current container
  80179. */
  80180. removeControl(control: Control3D): GUI3DManager;
  80181. /**
  80182. * Releases all associated resources
  80183. */
  80184. dispose(): void;
  80185. }
  80186. }
  80187. declare module BABYLON.GUI {
  80188. /**
  80189. * Class used to transport BABYLON.Vector3 information for pointer events
  80190. */
  80191. export class Vector3WithInfo extends BABYLON.Vector3 {
  80192. /** defines the current mouse button index */
  80193. buttonIndex: number;
  80194. /**
  80195. * Creates a new Vector3WithInfo
  80196. * @param source defines the vector3 data to transport
  80197. * @param buttonIndex defines the current mouse button index
  80198. */
  80199. constructor(source: BABYLON.Vector3,
  80200. /** defines the current mouse button index */
  80201. buttonIndex?: number);
  80202. }
  80203. }
  80204. declare module BABYLON.GUI {
  80205. /**
  80206. * Class used as base class for controls
  80207. */
  80208. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  80209. /** Defines the control name */
  80210. name?: string | undefined;
  80211. /** @hidden */
  80212. _host: GUI3DManager;
  80213. private _node;
  80214. private _downCount;
  80215. private _enterCount;
  80216. private _downPointerIds;
  80217. private _isVisible;
  80218. /** Gets or sets the control position in world space */
  80219. get position(): BABYLON.Vector3;
  80220. set position(value: BABYLON.Vector3);
  80221. /** Gets or sets the control scaling in world space */
  80222. get scaling(): BABYLON.Vector3;
  80223. set scaling(value: BABYLON.Vector3);
  80224. /** Callback used to start pointer enter animation */
  80225. pointerEnterAnimation: () => void;
  80226. /** Callback used to start pointer out animation */
  80227. pointerOutAnimation: () => void;
  80228. /** Callback used to start pointer down animation */
  80229. pointerDownAnimation: () => void;
  80230. /** Callback used to start pointer up animation */
  80231. pointerUpAnimation: () => void;
  80232. /**
  80233. * An event triggered when the pointer move over the control
  80234. */
  80235. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  80236. /**
  80237. * An event triggered when the pointer move out of the control
  80238. */
  80239. onPointerOutObservable: BABYLON.Observable<Control3D>;
  80240. /**
  80241. * An event triggered when the pointer taps the control
  80242. */
  80243. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  80244. /**
  80245. * An event triggered when pointer is up
  80246. */
  80247. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  80248. /**
  80249. * An event triggered when a control is clicked on (with a mouse)
  80250. */
  80251. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  80252. /**
  80253. * An event triggered when pointer enters the control
  80254. */
  80255. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  80256. /**
  80257. * Gets or sets the parent container
  80258. */
  80259. parent: BABYLON.Nullable<Container3D>;
  80260. private _behaviors;
  80261. /**
  80262. * Gets the list of attached behaviors
  80263. * @see https://doc.babylonjs.com/features/behaviour
  80264. */
  80265. get behaviors(): BABYLON.Behavior<Control3D>[];
  80266. /**
  80267. * Attach a behavior to the control
  80268. * @see https://doc.babylonjs.com/features/behaviour
  80269. * @param behavior defines the behavior to attach
  80270. * @returns the current control
  80271. */
  80272. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  80273. /**
  80274. * Remove an attached behavior
  80275. * @see https://doc.babylonjs.com/features/behaviour
  80276. * @param behavior defines the behavior to attach
  80277. * @returns the current control
  80278. */
  80279. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  80280. /**
  80281. * Gets an attached behavior by name
  80282. * @param name defines the name of the behavior to look for
  80283. * @see https://doc.babylonjs.com/features/behaviour
  80284. * @returns null if behavior was not found else the requested behavior
  80285. */
  80286. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  80287. /** Gets or sets a boolean indicating if the control is visible */
  80288. get isVisible(): boolean;
  80289. set isVisible(value: boolean);
  80290. /**
  80291. * Creates a new control
  80292. * @param name defines the control name
  80293. */
  80294. constructor(
  80295. /** Defines the control name */
  80296. name?: string | undefined);
  80297. /**
  80298. * Gets a string representing the class name
  80299. */
  80300. get typeName(): string;
  80301. /**
  80302. * Get the current class name of the control.
  80303. * @returns current class name
  80304. */
  80305. getClassName(): string;
  80306. protected _getTypeName(): string;
  80307. /**
  80308. * Gets the transform node used by this control
  80309. */
  80310. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  80311. /**
  80312. * Gets the mesh used to render this control
  80313. */
  80314. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  80315. /**
  80316. * Link the control as child of the given node
  80317. * @param node defines the node to link to. Use null to unlink the control
  80318. * @returns the current control
  80319. */
  80320. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  80321. /** @hidden **/
  80322. _prepareNode(scene: BABYLON.Scene): void;
  80323. /**
  80324. * Node creation.
  80325. * Can be overriden by children
  80326. * @param scene defines the scene where the node must be attached
  80327. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  80328. */
  80329. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  80330. /**
  80331. * Affect a material to the given mesh
  80332. * @param mesh defines the mesh which will represent the control
  80333. */
  80334. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  80335. /** @hidden */
  80336. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  80337. /** @hidden */
  80338. _onPointerEnter(target: Control3D): boolean;
  80339. /** @hidden */
  80340. _onPointerOut(target: Control3D): void;
  80341. /** @hidden */
  80342. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  80343. /** @hidden */
  80344. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  80345. /** @hidden */
  80346. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  80347. /** @hidden */
  80348. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  80349. /** @hidden */
  80350. _disposeNode(): void;
  80351. /**
  80352. * Releases all associated resources
  80353. */
  80354. dispose(): void;
  80355. }
  80356. }
  80357. declare module BABYLON.GUI {
  80358. /**
  80359. * Class used as a root to all buttons
  80360. */
  80361. export class AbstractButton3D extends Control3D {
  80362. /**
  80363. * Creates a new button
  80364. * @param name defines the control name
  80365. */
  80366. constructor(name?: string);
  80367. protected _getTypeName(): string;
  80368. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80369. }
  80370. }
  80371. declare module BABYLON.GUI {
  80372. /**
  80373. * Class used to create a button in 3D
  80374. */
  80375. export class Button3D extends AbstractButton3D {
  80376. /** @hidden */
  80377. protected _currentMaterial: BABYLON.Material;
  80378. private _facadeTexture;
  80379. private _content;
  80380. private _contentResolution;
  80381. private _contentScaleRatio;
  80382. /**
  80383. * Gets or sets the texture resolution used to render content (512 by default)
  80384. */
  80385. get contentResolution(): BABYLON.int;
  80386. set contentResolution(value: BABYLON.int);
  80387. /**
  80388. * Gets or sets the texture scale ratio used to render content (2 by default)
  80389. */
  80390. get contentScaleRatio(): number;
  80391. set contentScaleRatio(value: number);
  80392. protected _disposeFacadeTexture(): void;
  80393. protected _resetContent(): void;
  80394. /**
  80395. * Creates a new button
  80396. * @param name defines the control name
  80397. */
  80398. constructor(name?: string);
  80399. /**
  80400. * Gets or sets the GUI 2D content used to display the button's facade
  80401. */
  80402. get content(): Control;
  80403. set content(value: Control);
  80404. /**
  80405. * Apply the facade texture (created from the content property).
  80406. * This function can be overloaded by child classes
  80407. * @param facadeTexture defines the AdvancedDynamicTexture to use
  80408. */
  80409. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  80410. protected _getTypeName(): string;
  80411. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80412. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  80413. /**
  80414. * Releases all associated resources
  80415. */
  80416. dispose(): void;
  80417. }
  80418. }
  80419. declare module BABYLON.GUI {
  80420. /**
  80421. * Abstract class used to create a container panel deployed on the surface of a volume
  80422. */
  80423. export abstract class VolumeBasedPanel extends Container3D {
  80424. private _columns;
  80425. private _rows;
  80426. private _rowThenColum;
  80427. private _orientation;
  80428. protected _cellWidth: number;
  80429. protected _cellHeight: number;
  80430. /**
  80431. * Gets or sets the distance between elements
  80432. */
  80433. margin: number;
  80434. /**
  80435. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  80436. * | Value | Type | Description |
  80437. * | ----- | ----------------------------------- | ----------- |
  80438. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  80439. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  80440. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  80441. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  80442. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  80443. */
  80444. get orientation(): number;
  80445. set orientation(value: number);
  80446. /**
  80447. * Gets or sets the number of columns requested (10 by default).
  80448. * The panel will automatically compute the number of rows based on number of child controls.
  80449. */
  80450. get columns(): BABYLON.int;
  80451. set columns(value: BABYLON.int);
  80452. /**
  80453. * Gets or sets a the number of rows requested.
  80454. * The panel will automatically compute the number of columns based on number of child controls.
  80455. */
  80456. get rows(): BABYLON.int;
  80457. set rows(value: BABYLON.int);
  80458. /**
  80459. * Creates new VolumeBasedPanel
  80460. */
  80461. constructor();
  80462. protected _arrangeChildren(): void;
  80463. /** Child classes must implement this function to provide correct control positioning */
  80464. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80465. /** Child classes can implement this function to provide additional processing */
  80466. protected _finalProcessing(): void;
  80467. }
  80468. }
  80469. declare module BABYLON.GUI {
  80470. /**
  80471. * Class used to create a container panel deployed on the surface of a cylinder
  80472. */
  80473. export class CylinderPanel extends VolumeBasedPanel {
  80474. private _radius;
  80475. /**
  80476. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  80477. */
  80478. get radius(): BABYLON.float;
  80479. set radius(value: BABYLON.float);
  80480. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80481. private _cylindricalMapping;
  80482. }
  80483. }
  80484. declare module BABYLON.GUI {
  80485. /** @hidden */
  80486. export var fluentVertexShader: {
  80487. name: string;
  80488. shader: string;
  80489. };
  80490. }
  80491. declare module BABYLON.GUI {
  80492. /** @hidden */
  80493. export var fluentPixelShader: {
  80494. name: string;
  80495. shader: string;
  80496. };
  80497. }
  80498. declare module BABYLON.GUI {
  80499. /** @hidden */
  80500. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  80501. INNERGLOW: boolean;
  80502. BORDER: boolean;
  80503. HOVERLIGHT: boolean;
  80504. TEXTURE: boolean;
  80505. constructor();
  80506. }
  80507. /**
  80508. * Class used to render controls with fluent desgin
  80509. */
  80510. export class FluentMaterial extends BABYLON.PushMaterial {
  80511. /**
  80512. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  80513. */
  80514. innerGlowColorIntensity: number;
  80515. /**
  80516. * Gets or sets the inner glow color (white by default)
  80517. */
  80518. innerGlowColor: BABYLON.Color3;
  80519. /**
  80520. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  80521. */
  80522. albedoColor: BABYLON.Color3;
  80523. /**
  80524. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  80525. */
  80526. renderBorders: boolean;
  80527. /**
  80528. * Gets or sets border width (default is 0.5)
  80529. */
  80530. borderWidth: number;
  80531. /**
  80532. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  80533. */
  80534. edgeSmoothingValue: number;
  80535. /**
  80536. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  80537. */
  80538. borderMinValue: number;
  80539. /**
  80540. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  80541. */
  80542. renderHoverLight: boolean;
  80543. /**
  80544. * Gets or sets the radius used to render the hover light (default is 1.0)
  80545. */
  80546. hoverRadius: number;
  80547. /**
  80548. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  80549. */
  80550. hoverColor: BABYLON.Color4;
  80551. /**
  80552. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  80553. */
  80554. hoverPosition: BABYLON.Vector3;
  80555. private _albedoTexture;
  80556. /** Gets or sets the texture to use for albedo color */
  80557. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  80558. /**
  80559. * Creates a new Fluent material
  80560. * @param name defines the name of the material
  80561. * @param scene defines the hosting scene
  80562. */
  80563. constructor(name: string, scene: BABYLON.Scene);
  80564. needAlphaBlending(): boolean;
  80565. needAlphaTesting(): boolean;
  80566. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80567. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80568. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80569. getActiveTextures(): BABYLON.BaseTexture[];
  80570. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80571. dispose(forceDisposeEffect?: boolean): void;
  80572. clone(name: string): FluentMaterial;
  80573. serialize(): any;
  80574. getClassName(): string;
  80575. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  80576. }
  80577. }
  80578. declare module BABYLON.GUI {
  80579. /**
  80580. * Class used to create a holographic button in 3D
  80581. */
  80582. export class HolographicButton extends Button3D {
  80583. private _backPlate;
  80584. private _textPlate;
  80585. private _frontPlate;
  80586. private _text;
  80587. private _imageUrl;
  80588. private _shareMaterials;
  80589. private _frontMaterial;
  80590. private _backMaterial;
  80591. private _plateMaterial;
  80592. private _pickedPointObserver;
  80593. private _tooltipFade;
  80594. private _tooltipTextBlock;
  80595. private _tooltipTexture;
  80596. private _tooltipMesh;
  80597. private _tooltipHoverObserver;
  80598. private _tooltipOutObserver;
  80599. private _disposeTooltip;
  80600. /**
  80601. * Rendering ground id of all the mesh in the button
  80602. */
  80603. set renderingGroupId(id: number);
  80604. get renderingGroupId(): number;
  80605. /**
  80606. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  80607. */
  80608. set tooltipText(text: BABYLON.Nullable<string>);
  80609. get tooltipText(): BABYLON.Nullable<string>;
  80610. /**
  80611. * Gets or sets text for the button
  80612. */
  80613. get text(): string;
  80614. set text(value: string);
  80615. /**
  80616. * Gets or sets the image url for the button
  80617. */
  80618. get imageUrl(): string;
  80619. set imageUrl(value: string);
  80620. /**
  80621. * Gets the back material used by this button
  80622. */
  80623. get backMaterial(): FluentMaterial;
  80624. /**
  80625. * Gets the front material used by this button
  80626. */
  80627. get frontMaterial(): FluentMaterial;
  80628. /**
  80629. * Gets the plate material used by this button
  80630. */
  80631. get plateMaterial(): BABYLON.StandardMaterial;
  80632. /**
  80633. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  80634. */
  80635. get shareMaterials(): boolean;
  80636. /**
  80637. * Creates a new button
  80638. * @param name defines the control name
  80639. */
  80640. constructor(name?: string, shareMaterials?: boolean);
  80641. protected _getTypeName(): string;
  80642. private _rebuildContent;
  80643. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80644. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  80645. private _createBackMaterial;
  80646. private _createFrontMaterial;
  80647. private _createPlateMaterial;
  80648. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  80649. /**
  80650. * Releases all associated resources
  80651. */
  80652. dispose(): void;
  80653. }
  80654. }
  80655. declare module BABYLON.GUI {
  80656. /**
  80657. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  80658. */
  80659. export class MeshButton3D extends Button3D {
  80660. /** @hidden */
  80661. protected _currentMesh: BABYLON.Mesh;
  80662. /**
  80663. * Creates a new 3D button based on a mesh
  80664. * @param mesh mesh to become a 3D button
  80665. * @param name defines the control name
  80666. */
  80667. constructor(mesh: BABYLON.Mesh, name?: string);
  80668. protected _getTypeName(): string;
  80669. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80670. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  80671. }
  80672. }
  80673. declare module BABYLON.GUI {
  80674. /**
  80675. * Class used to create a container panel deployed on the surface of a plane
  80676. */
  80677. export class PlanePanel extends VolumeBasedPanel {
  80678. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80679. }
  80680. }
  80681. declare module BABYLON.GUI {
  80682. /**
  80683. * Class used to create a container panel where items get randomized planar mapping
  80684. */
  80685. export class ScatterPanel extends VolumeBasedPanel {
  80686. private _iteration;
  80687. /**
  80688. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  80689. */
  80690. get iteration(): BABYLON.float;
  80691. set iteration(value: BABYLON.float);
  80692. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80693. private _scatterMapping;
  80694. protected _finalProcessing(): void;
  80695. }
  80696. }
  80697. declare module BABYLON.GUI {
  80698. /**
  80699. * Class used to create a container panel deployed on the surface of a sphere
  80700. */
  80701. export class SpherePanel extends VolumeBasedPanel {
  80702. private _radius;
  80703. /**
  80704. * Gets or sets the radius of the sphere where to project controls (5 by default)
  80705. */
  80706. get radius(): BABYLON.float;
  80707. set radius(value: BABYLON.float);
  80708. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80709. private _sphericalMapping;
  80710. }
  80711. }
  80712. declare module BABYLON.GUI {
  80713. /**
  80714. * Class used to create a stack panel in 3D on XY plane
  80715. */
  80716. export class StackPanel3D extends Container3D {
  80717. private _isVertical;
  80718. /**
  80719. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  80720. */
  80721. get isVertical(): boolean;
  80722. set isVertical(value: boolean);
  80723. /**
  80724. * Gets or sets the distance between elements
  80725. */
  80726. margin: number;
  80727. /**
  80728. * Creates new StackPanel
  80729. * @param isVertical
  80730. */
  80731. constructor(isVertical?: boolean);
  80732. protected _arrangeChildren(): void;
  80733. }
  80734. }
  80735. declare module BABYLON {
  80736. /**
  80737. * Configuration for glTF validation
  80738. */
  80739. export interface IGLTFValidationConfiguration {
  80740. /**
  80741. * The url of the glTF validator.
  80742. */
  80743. url: string;
  80744. }
  80745. /**
  80746. * glTF validation
  80747. */
  80748. export class GLTFValidation {
  80749. /**
  80750. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  80751. */
  80752. static Configuration: IGLTFValidationConfiguration;
  80753. private static _LoadScriptPromise;
  80754. /**
  80755. * Validate a glTF asset using the glTF-Validator.
  80756. * @param data The JSON of a glTF or the array buffer of a binary glTF
  80757. * @param rootUrl The root url for the glTF
  80758. * @param fileName The file name for the glTF
  80759. * @param getExternalResource The callback to get external resources for the glTF validator
  80760. * @returns A promise that resolves with the glTF validation results once complete
  80761. */
  80762. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  80763. }
  80764. }
  80765. declare module BABYLON {
  80766. /**
  80767. * Mode that determines the coordinate system to use.
  80768. */
  80769. export enum GLTFLoaderCoordinateSystemMode {
  80770. /**
  80771. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  80772. */
  80773. AUTO = 0,
  80774. /**
  80775. * Sets the useRightHandedSystem flag on the scene.
  80776. */
  80777. FORCE_RIGHT_HANDED = 1
  80778. }
  80779. /**
  80780. * Mode that determines what animations will start.
  80781. */
  80782. export enum GLTFLoaderAnimationStartMode {
  80783. /**
  80784. * No animation will start.
  80785. */
  80786. NONE = 0,
  80787. /**
  80788. * The first animation will start.
  80789. */
  80790. FIRST = 1,
  80791. /**
  80792. * All animations will start.
  80793. */
  80794. ALL = 2
  80795. }
  80796. /**
  80797. * Interface that contains the data for the glTF asset.
  80798. */
  80799. export interface IGLTFLoaderData {
  80800. /**
  80801. * The object that represents the glTF JSON.
  80802. */
  80803. json: Object;
  80804. /**
  80805. * The BIN chunk of a binary glTF.
  80806. */
  80807. bin: Nullable<IDataBuffer>;
  80808. }
  80809. /**
  80810. * Interface for extending the loader.
  80811. */
  80812. export interface IGLTFLoaderExtension {
  80813. /**
  80814. * The name of this extension.
  80815. */
  80816. readonly name: string;
  80817. /**
  80818. * Defines whether this extension is enabled.
  80819. */
  80820. enabled: boolean;
  80821. /**
  80822. * Defines the order of this extension.
  80823. * The loader sorts the extensions using these values when loading.
  80824. */
  80825. order?: number;
  80826. }
  80827. /**
  80828. * Loader state.
  80829. */
  80830. export enum GLTFLoaderState {
  80831. /**
  80832. * The asset is loading.
  80833. */
  80834. LOADING = 0,
  80835. /**
  80836. * The asset is ready for rendering.
  80837. */
  80838. READY = 1,
  80839. /**
  80840. * The asset is completely loaded.
  80841. */
  80842. COMPLETE = 2
  80843. }
  80844. /** @hidden */
  80845. export interface IImportMeshAsyncOutput {
  80846. meshes: AbstractMesh[];
  80847. particleSystems: IParticleSystem[];
  80848. skeletons: Skeleton[];
  80849. animationGroups: AnimationGroup[];
  80850. lights: Light[];
  80851. transformNodes: TransformNode[];
  80852. }
  80853. /** @hidden */
  80854. export interface IGLTFLoader extends IDisposable {
  80855. readonly state: Nullable<GLTFLoaderState>;
  80856. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  80857. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  80858. }
  80859. /**
  80860. * File loader for loading glTF files into a scene.
  80861. */
  80862. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  80863. /** @hidden */
  80864. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  80865. /** @hidden */
  80866. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  80867. /**
  80868. * Raised when the asset has been parsed
  80869. */
  80870. onParsedObservable: Observable<IGLTFLoaderData>;
  80871. private _onParsedObserver;
  80872. /**
  80873. * Raised when the asset has been parsed
  80874. */
  80875. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  80876. /**
  80877. * 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.
  80878. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  80879. * Defaults to true.
  80880. * @hidden
  80881. */
  80882. static IncrementalLoading: boolean;
  80883. /**
  80884. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  80885. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  80886. * @hidden
  80887. */
  80888. static HomogeneousCoordinates: boolean;
  80889. /**
  80890. * The coordinate system mode. Defaults to AUTO.
  80891. */
  80892. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  80893. /**
  80894. * The animation start mode. Defaults to FIRST.
  80895. */
  80896. animationStartMode: GLTFLoaderAnimationStartMode;
  80897. /**
  80898. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  80899. */
  80900. compileMaterials: boolean;
  80901. /**
  80902. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  80903. */
  80904. useClipPlane: boolean;
  80905. /**
  80906. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  80907. */
  80908. compileShadowGenerators: boolean;
  80909. /**
  80910. * Defines if the Alpha blended materials are only applied as coverage.
  80911. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  80912. * If true, no extra effects are applied to transparent pixels.
  80913. */
  80914. transparencyAsCoverage: boolean;
  80915. /**
  80916. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  80917. * Enabling will disable offline support and glTF validator.
  80918. * Defaults to false.
  80919. */
  80920. useRangeRequests: boolean;
  80921. /**
  80922. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  80923. */
  80924. createInstances: boolean;
  80925. /**
  80926. * 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.
  80927. */
  80928. alwaysComputeBoundingBox: boolean;
  80929. /**
  80930. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  80931. */
  80932. loadAllMaterials: boolean;
  80933. /**
  80934. * Function called before loading a url referenced by the asset.
  80935. */
  80936. preprocessUrlAsync: (url: string) => Promise<string>;
  80937. /**
  80938. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  80939. * 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, ...)
  80940. */
  80941. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  80942. private _onMeshLoadedObserver;
  80943. /**
  80944. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  80945. * 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, ...)
  80946. */
  80947. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  80948. /**
  80949. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  80950. */
  80951. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  80952. private _onTextureLoadedObserver;
  80953. /**
  80954. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  80955. */
  80956. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  80957. /**
  80958. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  80959. */
  80960. readonly onMaterialLoadedObservable: Observable<Material>;
  80961. private _onMaterialLoadedObserver;
  80962. /**
  80963. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  80964. */
  80965. set onMaterialLoaded(callback: (material: Material) => void);
  80966. /**
  80967. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  80968. */
  80969. readonly onCameraLoadedObservable: Observable<Camera>;
  80970. private _onCameraLoadedObserver;
  80971. /**
  80972. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  80973. */
  80974. set onCameraLoaded(callback: (camera: Camera) => void);
  80975. /**
  80976. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  80977. * For assets with LODs, raised when all of the LODs are complete.
  80978. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  80979. */
  80980. readonly onCompleteObservable: Observable<void>;
  80981. private _onCompleteObserver;
  80982. /**
  80983. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  80984. * For assets with LODs, raised when all of the LODs are complete.
  80985. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  80986. */
  80987. set onComplete(callback: () => void);
  80988. /**
  80989. * Observable raised when an error occurs.
  80990. */
  80991. readonly onErrorObservable: Observable<any>;
  80992. private _onErrorObserver;
  80993. /**
  80994. * Callback raised when an error occurs.
  80995. */
  80996. set onError(callback: (reason: any) => void);
  80997. /**
  80998. * Observable raised after the loader is disposed.
  80999. */
  81000. readonly onDisposeObservable: Observable<void>;
  81001. private _onDisposeObserver;
  81002. /**
  81003. * Callback raised after the loader is disposed.
  81004. */
  81005. set onDispose(callback: () => void);
  81006. /**
  81007. * Observable raised after a loader extension is created.
  81008. * Set additional options for a loader extension in this event.
  81009. */
  81010. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  81011. private _onExtensionLoadedObserver;
  81012. /**
  81013. * Callback raised after a loader extension is created.
  81014. */
  81015. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  81016. /**
  81017. * Defines if the loader logging is enabled.
  81018. */
  81019. get loggingEnabled(): boolean;
  81020. set loggingEnabled(value: boolean);
  81021. /**
  81022. * Defines if the loader should capture performance counters.
  81023. */
  81024. get capturePerformanceCounters(): boolean;
  81025. set capturePerformanceCounters(value: boolean);
  81026. /**
  81027. * Defines if the loader should validate the asset.
  81028. */
  81029. validate: boolean;
  81030. /**
  81031. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  81032. */
  81033. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  81034. private _onValidatedObserver;
  81035. /**
  81036. * Callback raised after a loader extension is created.
  81037. */
  81038. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  81039. private _loader;
  81040. private _progressCallback?;
  81041. private _requests;
  81042. private static magicBase64Encoded;
  81043. /**
  81044. * Name of the loader ("gltf")
  81045. */
  81046. name: string;
  81047. /** @hidden */
  81048. extensions: ISceneLoaderPluginExtensions;
  81049. /**
  81050. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  81051. */
  81052. dispose(): void;
  81053. /** @hidden */
  81054. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  81055. /** @hidden */
  81056. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  81057. /** @hidden */
  81058. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  81059. meshes: AbstractMesh[];
  81060. particleSystems: IParticleSystem[];
  81061. skeletons: Skeleton[];
  81062. animationGroups: AnimationGroup[];
  81063. }>;
  81064. /** @hidden */
  81065. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  81066. /** @hidden */
  81067. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  81068. /** @hidden */
  81069. canDirectLoad(data: string): boolean;
  81070. /** @hidden */
  81071. directLoad(scene: Scene, data: string): Promise<any>;
  81072. /**
  81073. * The callback that allows custom handling of the root url based on the response url.
  81074. * @param rootUrl the original root url
  81075. * @param responseURL the response url if available
  81076. * @returns the new root url
  81077. */
  81078. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  81079. /** @hidden */
  81080. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  81081. /**
  81082. * The loader state or null if the loader is not active.
  81083. */
  81084. get loaderState(): Nullable<GLTFLoaderState>;
  81085. /**
  81086. * Returns a promise that resolves when the asset is completely loaded.
  81087. * @returns a promise that resolves when the asset is completely loaded.
  81088. */
  81089. whenCompleteAsync(): Promise<void>;
  81090. /** @hidden */
  81091. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  81092. /** @hidden */
  81093. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  81094. private _onProgress;
  81095. private _validate;
  81096. private _getLoader;
  81097. private _parseJson;
  81098. private _unpackBinaryAsync;
  81099. private _unpackBinaryV1Async;
  81100. private _unpackBinaryV2Async;
  81101. private static _parseVersion;
  81102. private static _compareVersion;
  81103. private static readonly _logSpaces;
  81104. private _logIndentLevel;
  81105. private _loggingEnabled;
  81106. /** @hidden */
  81107. _log: (message: string) => void;
  81108. /** @hidden */
  81109. _logOpen(message: string): void;
  81110. /** @hidden */
  81111. _logClose(): void;
  81112. private _logEnabled;
  81113. private _logDisabled;
  81114. private _capturePerformanceCounters;
  81115. /** @hidden */
  81116. _startPerformanceCounter: (counterName: string) => void;
  81117. /** @hidden */
  81118. _endPerformanceCounter: (counterName: string) => void;
  81119. private _startPerformanceCounterEnabled;
  81120. private _startPerformanceCounterDisabled;
  81121. private _endPerformanceCounterEnabled;
  81122. private _endPerformanceCounterDisabled;
  81123. }
  81124. }
  81125. declare module BABYLON.GLTF1 {
  81126. /**
  81127. * Enums
  81128. * @hidden
  81129. */
  81130. export enum EComponentType {
  81131. BYTE = 5120,
  81132. UNSIGNED_BYTE = 5121,
  81133. SHORT = 5122,
  81134. UNSIGNED_SHORT = 5123,
  81135. FLOAT = 5126
  81136. }
  81137. /** @hidden */
  81138. export enum EShaderType {
  81139. FRAGMENT = 35632,
  81140. VERTEX = 35633
  81141. }
  81142. /** @hidden */
  81143. export enum EParameterType {
  81144. BYTE = 5120,
  81145. UNSIGNED_BYTE = 5121,
  81146. SHORT = 5122,
  81147. UNSIGNED_SHORT = 5123,
  81148. INT = 5124,
  81149. UNSIGNED_INT = 5125,
  81150. FLOAT = 5126,
  81151. FLOAT_VEC2 = 35664,
  81152. FLOAT_VEC3 = 35665,
  81153. FLOAT_VEC4 = 35666,
  81154. INT_VEC2 = 35667,
  81155. INT_VEC3 = 35668,
  81156. INT_VEC4 = 35669,
  81157. BOOL = 35670,
  81158. BOOL_VEC2 = 35671,
  81159. BOOL_VEC3 = 35672,
  81160. BOOL_VEC4 = 35673,
  81161. FLOAT_MAT2 = 35674,
  81162. FLOAT_MAT3 = 35675,
  81163. FLOAT_MAT4 = 35676,
  81164. SAMPLER_2D = 35678
  81165. }
  81166. /** @hidden */
  81167. export enum ETextureWrapMode {
  81168. CLAMP_TO_EDGE = 33071,
  81169. MIRRORED_REPEAT = 33648,
  81170. REPEAT = 10497
  81171. }
  81172. /** @hidden */
  81173. export enum ETextureFilterType {
  81174. NEAREST = 9728,
  81175. LINEAR = 9728,
  81176. NEAREST_MIPMAP_NEAREST = 9984,
  81177. LINEAR_MIPMAP_NEAREST = 9985,
  81178. NEAREST_MIPMAP_LINEAR = 9986,
  81179. LINEAR_MIPMAP_LINEAR = 9987
  81180. }
  81181. /** @hidden */
  81182. export enum ETextureFormat {
  81183. ALPHA = 6406,
  81184. RGB = 6407,
  81185. RGBA = 6408,
  81186. LUMINANCE = 6409,
  81187. LUMINANCE_ALPHA = 6410
  81188. }
  81189. /** @hidden */
  81190. export enum ECullingType {
  81191. FRONT = 1028,
  81192. BACK = 1029,
  81193. FRONT_AND_BACK = 1032
  81194. }
  81195. /** @hidden */
  81196. export enum EBlendingFunction {
  81197. ZERO = 0,
  81198. ONE = 1,
  81199. SRC_COLOR = 768,
  81200. ONE_MINUS_SRC_COLOR = 769,
  81201. DST_COLOR = 774,
  81202. ONE_MINUS_DST_COLOR = 775,
  81203. SRC_ALPHA = 770,
  81204. ONE_MINUS_SRC_ALPHA = 771,
  81205. DST_ALPHA = 772,
  81206. ONE_MINUS_DST_ALPHA = 773,
  81207. CONSTANT_COLOR = 32769,
  81208. ONE_MINUS_CONSTANT_COLOR = 32770,
  81209. CONSTANT_ALPHA = 32771,
  81210. ONE_MINUS_CONSTANT_ALPHA = 32772,
  81211. SRC_ALPHA_SATURATE = 776
  81212. }
  81213. /** @hidden */
  81214. export interface IGLTFProperty {
  81215. extensions?: {
  81216. [key: string]: any;
  81217. };
  81218. extras?: Object;
  81219. }
  81220. /** @hidden */
  81221. export interface IGLTFChildRootProperty extends IGLTFProperty {
  81222. name?: string;
  81223. }
  81224. /** @hidden */
  81225. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  81226. bufferView: string;
  81227. byteOffset: number;
  81228. byteStride: number;
  81229. count: number;
  81230. type: string;
  81231. componentType: EComponentType;
  81232. max?: number[];
  81233. min?: number[];
  81234. name?: string;
  81235. }
  81236. /** @hidden */
  81237. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  81238. buffer: string;
  81239. byteOffset: number;
  81240. byteLength: number;
  81241. byteStride: number;
  81242. target?: number;
  81243. }
  81244. /** @hidden */
  81245. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  81246. uri: string;
  81247. byteLength?: number;
  81248. type?: string;
  81249. }
  81250. /** @hidden */
  81251. export interface IGLTFShader extends IGLTFChildRootProperty {
  81252. uri: string;
  81253. type: EShaderType;
  81254. }
  81255. /** @hidden */
  81256. export interface IGLTFProgram extends IGLTFChildRootProperty {
  81257. attributes: string[];
  81258. fragmentShader: string;
  81259. vertexShader: string;
  81260. }
  81261. /** @hidden */
  81262. export interface IGLTFTechniqueParameter {
  81263. type: number;
  81264. count?: number;
  81265. semantic?: string;
  81266. node?: string;
  81267. value?: number | boolean | string | Array<any>;
  81268. source?: string;
  81269. babylonValue?: any;
  81270. }
  81271. /** @hidden */
  81272. export interface IGLTFTechniqueCommonProfile {
  81273. lightingModel: string;
  81274. texcoordBindings: Object;
  81275. parameters?: Array<any>;
  81276. }
  81277. /** @hidden */
  81278. export interface IGLTFTechniqueStatesFunctions {
  81279. blendColor?: number[];
  81280. blendEquationSeparate?: number[];
  81281. blendFuncSeparate?: number[];
  81282. colorMask: boolean[];
  81283. cullFace: number[];
  81284. }
  81285. /** @hidden */
  81286. export interface IGLTFTechniqueStates {
  81287. enable: number[];
  81288. functions: IGLTFTechniqueStatesFunctions;
  81289. }
  81290. /** @hidden */
  81291. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  81292. parameters: {
  81293. [key: string]: IGLTFTechniqueParameter;
  81294. };
  81295. program: string;
  81296. attributes: {
  81297. [key: string]: string;
  81298. };
  81299. uniforms: {
  81300. [key: string]: string;
  81301. };
  81302. states: IGLTFTechniqueStates;
  81303. }
  81304. /** @hidden */
  81305. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  81306. technique?: string;
  81307. values: string[];
  81308. }
  81309. /** @hidden */
  81310. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  81311. attributes: {
  81312. [key: string]: string;
  81313. };
  81314. indices: string;
  81315. material: string;
  81316. mode?: number;
  81317. }
  81318. /** @hidden */
  81319. export interface IGLTFMesh extends IGLTFChildRootProperty {
  81320. primitives: IGLTFMeshPrimitive[];
  81321. }
  81322. /** @hidden */
  81323. export interface IGLTFImage extends IGLTFChildRootProperty {
  81324. uri: string;
  81325. }
  81326. /** @hidden */
  81327. export interface IGLTFSampler extends IGLTFChildRootProperty {
  81328. magFilter?: number;
  81329. minFilter?: number;
  81330. wrapS?: number;
  81331. wrapT?: number;
  81332. }
  81333. /** @hidden */
  81334. export interface IGLTFTexture extends IGLTFChildRootProperty {
  81335. sampler: string;
  81336. source: string;
  81337. format?: ETextureFormat;
  81338. internalFormat?: ETextureFormat;
  81339. target?: number;
  81340. type?: number;
  81341. babylonTexture?: Texture;
  81342. }
  81343. /** @hidden */
  81344. export interface IGLTFAmbienLight {
  81345. color?: number[];
  81346. }
  81347. /** @hidden */
  81348. export interface IGLTFDirectionalLight {
  81349. color?: number[];
  81350. }
  81351. /** @hidden */
  81352. export interface IGLTFPointLight {
  81353. color?: number[];
  81354. constantAttenuation?: number;
  81355. linearAttenuation?: number;
  81356. quadraticAttenuation?: number;
  81357. }
  81358. /** @hidden */
  81359. export interface IGLTFSpotLight {
  81360. color?: number[];
  81361. constantAttenuation?: number;
  81362. fallOfAngle?: number;
  81363. fallOffExponent?: number;
  81364. linearAttenuation?: number;
  81365. quadraticAttenuation?: number;
  81366. }
  81367. /** @hidden */
  81368. export interface IGLTFLight extends IGLTFChildRootProperty {
  81369. type: string;
  81370. }
  81371. /** @hidden */
  81372. export interface IGLTFCameraOrthographic {
  81373. xmag: number;
  81374. ymag: number;
  81375. zfar: number;
  81376. znear: number;
  81377. }
  81378. /** @hidden */
  81379. export interface IGLTFCameraPerspective {
  81380. aspectRatio: number;
  81381. yfov: number;
  81382. zfar: number;
  81383. znear: number;
  81384. }
  81385. /** @hidden */
  81386. export interface IGLTFCamera extends IGLTFChildRootProperty {
  81387. type: string;
  81388. }
  81389. /** @hidden */
  81390. export interface IGLTFAnimationChannelTarget {
  81391. id: string;
  81392. path: string;
  81393. }
  81394. /** @hidden */
  81395. export interface IGLTFAnimationChannel {
  81396. sampler: string;
  81397. target: IGLTFAnimationChannelTarget;
  81398. }
  81399. /** @hidden */
  81400. export interface IGLTFAnimationSampler {
  81401. input: string;
  81402. output: string;
  81403. interpolation?: string;
  81404. }
  81405. /** @hidden */
  81406. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  81407. channels?: IGLTFAnimationChannel[];
  81408. parameters?: {
  81409. [key: string]: string;
  81410. };
  81411. samplers?: {
  81412. [key: string]: IGLTFAnimationSampler;
  81413. };
  81414. }
  81415. /** @hidden */
  81416. export interface IGLTFNodeInstanceSkin {
  81417. skeletons: string[];
  81418. skin: string;
  81419. meshes: string[];
  81420. }
  81421. /** @hidden */
  81422. export interface IGLTFSkins extends IGLTFChildRootProperty {
  81423. bindShapeMatrix: number[];
  81424. inverseBindMatrices: string;
  81425. jointNames: string[];
  81426. babylonSkeleton?: Skeleton;
  81427. }
  81428. /** @hidden */
  81429. export interface IGLTFNode extends IGLTFChildRootProperty {
  81430. camera?: string;
  81431. children: string[];
  81432. skin?: string;
  81433. jointName?: string;
  81434. light?: string;
  81435. matrix: number[];
  81436. mesh?: string;
  81437. meshes?: string[];
  81438. rotation?: number[];
  81439. scale?: number[];
  81440. translation?: number[];
  81441. babylonNode?: Node;
  81442. }
  81443. /** @hidden */
  81444. export interface IGLTFScene extends IGLTFChildRootProperty {
  81445. nodes: string[];
  81446. }
  81447. /** @hidden */
  81448. export interface IGLTFRuntime {
  81449. extensions: {
  81450. [key: string]: any;
  81451. };
  81452. accessors: {
  81453. [key: string]: IGLTFAccessor;
  81454. };
  81455. buffers: {
  81456. [key: string]: IGLTFBuffer;
  81457. };
  81458. bufferViews: {
  81459. [key: string]: IGLTFBufferView;
  81460. };
  81461. meshes: {
  81462. [key: string]: IGLTFMesh;
  81463. };
  81464. lights: {
  81465. [key: string]: IGLTFLight;
  81466. };
  81467. cameras: {
  81468. [key: string]: IGLTFCamera;
  81469. };
  81470. nodes: {
  81471. [key: string]: IGLTFNode;
  81472. };
  81473. images: {
  81474. [key: string]: IGLTFImage;
  81475. };
  81476. textures: {
  81477. [key: string]: IGLTFTexture;
  81478. };
  81479. shaders: {
  81480. [key: string]: IGLTFShader;
  81481. };
  81482. programs: {
  81483. [key: string]: IGLTFProgram;
  81484. };
  81485. samplers: {
  81486. [key: string]: IGLTFSampler;
  81487. };
  81488. techniques: {
  81489. [key: string]: IGLTFTechnique;
  81490. };
  81491. materials: {
  81492. [key: string]: IGLTFMaterial;
  81493. };
  81494. animations: {
  81495. [key: string]: IGLTFAnimation;
  81496. };
  81497. skins: {
  81498. [key: string]: IGLTFSkins;
  81499. };
  81500. currentScene?: Object;
  81501. scenes: {
  81502. [key: string]: IGLTFScene;
  81503. };
  81504. extensionsUsed: string[];
  81505. extensionsRequired?: string[];
  81506. buffersCount: number;
  81507. shaderscount: number;
  81508. scene: Scene;
  81509. rootUrl: string;
  81510. loadedBufferCount: number;
  81511. loadedBufferViews: {
  81512. [name: string]: ArrayBufferView;
  81513. };
  81514. loadedShaderCount: number;
  81515. importOnlyMeshes: boolean;
  81516. importMeshesNames?: string[];
  81517. dummyNodes: Node[];
  81518. forAssetContainer: boolean;
  81519. }
  81520. /** @hidden */
  81521. export interface INodeToRoot {
  81522. bone: Bone;
  81523. node: IGLTFNode;
  81524. id: string;
  81525. }
  81526. /** @hidden */
  81527. export interface IJointNode {
  81528. node: IGLTFNode;
  81529. id: string;
  81530. }
  81531. }
  81532. declare module BABYLON.GLTF1 {
  81533. /**
  81534. * Utils functions for GLTF
  81535. * @hidden
  81536. */
  81537. export class GLTFUtils {
  81538. /**
  81539. * Sets the given "parameter" matrix
  81540. * @param scene: the Scene object
  81541. * @param source: the source node where to pick the matrix
  81542. * @param parameter: the GLTF technique parameter
  81543. * @param uniformName: the name of the shader's uniform
  81544. * @param shaderMaterial: the shader material
  81545. */
  81546. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  81547. /**
  81548. * Sets the given "parameter" matrix
  81549. * @param shaderMaterial: the shader material
  81550. * @param uniform: the name of the shader's uniform
  81551. * @param value: the value of the uniform
  81552. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  81553. */
  81554. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  81555. /**
  81556. * Returns the wrap mode of the texture
  81557. * @param mode: the mode value
  81558. */
  81559. static GetWrapMode(mode: number): number;
  81560. /**
  81561. * Returns the byte stride giving an accessor
  81562. * @param accessor: the GLTF accessor objet
  81563. */
  81564. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  81565. /**
  81566. * Returns the texture filter mode giving a mode value
  81567. * @param mode: the filter mode value
  81568. */
  81569. static GetTextureFilterMode(mode: number): ETextureFilterType;
  81570. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  81571. /**
  81572. * Returns a buffer from its accessor
  81573. * @param gltfRuntime: the GLTF runtime
  81574. * @param accessor: the GLTF accessor
  81575. */
  81576. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  81577. /**
  81578. * Decodes a buffer view into a string
  81579. * @param view: the buffer view
  81580. */
  81581. static DecodeBufferToText(view: ArrayBufferView): string;
  81582. /**
  81583. * Returns the default material of gltf. Related to
  81584. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  81585. * @param scene: the Babylon.js scene
  81586. */
  81587. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  81588. private static _DefaultMaterial;
  81589. }
  81590. }
  81591. declare module BABYLON.GLTF1 {
  81592. /**
  81593. * Implementation of the base glTF spec
  81594. * @hidden
  81595. */
  81596. export class GLTFLoaderBase {
  81597. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  81598. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  81599. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  81600. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  81601. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  81602. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  81603. }
  81604. /**
  81605. * glTF V1 Loader
  81606. * @hidden
  81607. */
  81608. export class GLTFLoader implements IGLTFLoader {
  81609. static Extensions: {
  81610. [name: string]: GLTFLoaderExtension;
  81611. };
  81612. static RegisterExtension(extension: GLTFLoaderExtension): void;
  81613. state: Nullable<GLTFLoaderState>;
  81614. dispose(): void;
  81615. private _importMeshAsync;
  81616. /**
  81617. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  81618. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  81619. * @param scene the scene the meshes should be added to
  81620. * @param forAssetContainer defines if the entities must be stored in the scene
  81621. * @param data gltf data containing information of the meshes in a loaded file
  81622. * @param rootUrl root url to load from
  81623. * @param onProgress event that fires when loading progress has occured
  81624. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  81625. */
  81626. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  81627. private _loadAsync;
  81628. /**
  81629. * Imports all objects from a loaded gltf file and adds them to the scene
  81630. * @param scene the scene the objects should be added to
  81631. * @param data gltf data containing information of the meshes in a loaded file
  81632. * @param rootUrl root url to load from
  81633. * @param onProgress event that fires when loading progress has occured
  81634. * @returns a promise which completes when objects have been loaded to the scene
  81635. */
  81636. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  81637. private _loadShadersAsync;
  81638. private _loadBuffersAsync;
  81639. private _createNodes;
  81640. }
  81641. /** @hidden */
  81642. export abstract class GLTFLoaderExtension {
  81643. private _name;
  81644. constructor(name: string);
  81645. get name(): string;
  81646. /**
  81647. * Defines an override for loading the runtime
  81648. * Return true to stop further extensions from loading the runtime
  81649. */
  81650. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  81651. /**
  81652. * Defines an onverride for creating gltf runtime
  81653. * Return true to stop further extensions from creating the runtime
  81654. */
  81655. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  81656. /**
  81657. * Defines an override for loading buffers
  81658. * Return true to stop further extensions from loading this buffer
  81659. */
  81660. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  81661. /**
  81662. * Defines an override for loading texture buffers
  81663. * Return true to stop further extensions from loading this texture data
  81664. */
  81665. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  81666. /**
  81667. * Defines an override for creating textures
  81668. * Return true to stop further extensions from loading this texture
  81669. */
  81670. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  81671. /**
  81672. * Defines an override for loading shader strings
  81673. * Return true to stop further extensions from loading this shader data
  81674. */
  81675. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  81676. /**
  81677. * Defines an override for loading materials
  81678. * Return true to stop further extensions from loading this material
  81679. */
  81680. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  81681. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  81682. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  81683. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  81684. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  81685. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  81686. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  81687. private static LoadTextureBufferAsync;
  81688. private static CreateTextureAsync;
  81689. private static ApplyExtensions;
  81690. }
  81691. }
  81692. declare module BABYLON.GLTF1 {
  81693. /** @hidden */
  81694. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  81695. private _bin;
  81696. constructor();
  81697. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  81698. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  81699. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  81700. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  81701. }
  81702. }
  81703. declare module BABYLON.GLTF1 {
  81704. /** @hidden */
  81705. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  81706. constructor();
  81707. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  81708. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  81709. private _loadTexture;
  81710. }
  81711. }
  81712. declare module BABYLON.GLTF2.Loader {
  81713. /**
  81714. * Loader interface with an index field.
  81715. */
  81716. export interface IArrayItem {
  81717. /**
  81718. * The index of this item in the array.
  81719. */
  81720. index: number;
  81721. }
  81722. /**
  81723. * Loader interface with additional members.
  81724. */
  81725. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  81726. /** @hidden */
  81727. _data?: Promise<ArrayBufferView>;
  81728. /** @hidden */
  81729. _babylonVertexBuffer?: Promise<VertexBuffer>;
  81730. }
  81731. /**
  81732. * Loader interface with additional members.
  81733. */
  81734. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  81735. }
  81736. /** @hidden */
  81737. export interface _IAnimationSamplerData {
  81738. input: Float32Array;
  81739. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  81740. output: Float32Array;
  81741. }
  81742. /**
  81743. * Loader interface with additional members.
  81744. */
  81745. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  81746. /** @hidden */
  81747. _data?: Promise<_IAnimationSamplerData>;
  81748. }
  81749. /**
  81750. * Loader interface with additional members.
  81751. */
  81752. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  81753. channels: IAnimationChannel[];
  81754. samplers: IAnimationSampler[];
  81755. /** @hidden */
  81756. _babylonAnimationGroup?: AnimationGroup;
  81757. }
  81758. /**
  81759. * Loader interface with additional members.
  81760. */
  81761. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  81762. /** @hidden */
  81763. _data?: Promise<ArrayBufferView>;
  81764. }
  81765. /**
  81766. * Loader interface with additional members.
  81767. */
  81768. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  81769. /** @hidden */
  81770. _data?: Promise<ArrayBufferView>;
  81771. /** @hidden */
  81772. _babylonBuffer?: Promise<Buffer>;
  81773. }
  81774. /**
  81775. * Loader interface with additional members.
  81776. */
  81777. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  81778. }
  81779. /**
  81780. * Loader interface with additional members.
  81781. */
  81782. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  81783. /** @hidden */
  81784. _data?: Promise<ArrayBufferView>;
  81785. }
  81786. /**
  81787. * Loader interface with additional members.
  81788. */
  81789. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  81790. }
  81791. /**
  81792. * Loader interface with additional members.
  81793. */
  81794. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  81795. }
  81796. /**
  81797. * Loader interface with additional members.
  81798. */
  81799. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  81800. baseColorTexture?: ITextureInfo;
  81801. metallicRoughnessTexture?: ITextureInfo;
  81802. }
  81803. /**
  81804. * Loader interface with additional members.
  81805. */
  81806. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  81807. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  81808. normalTexture?: IMaterialNormalTextureInfo;
  81809. occlusionTexture?: IMaterialOcclusionTextureInfo;
  81810. emissiveTexture?: ITextureInfo;
  81811. /** @hidden */
  81812. _data?: {
  81813. [babylonDrawMode: number]: {
  81814. babylonMaterial: Material;
  81815. babylonMeshes: AbstractMesh[];
  81816. promise: Promise<void>;
  81817. };
  81818. };
  81819. }
  81820. /**
  81821. * Loader interface with additional members.
  81822. */
  81823. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  81824. primitives: IMeshPrimitive[];
  81825. }
  81826. /**
  81827. * Loader interface with additional members.
  81828. */
  81829. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  81830. /** @hidden */
  81831. _instanceData?: {
  81832. babylonSourceMesh: Mesh;
  81833. promise: Promise<any>;
  81834. };
  81835. }
  81836. /**
  81837. * Loader interface with additional members.
  81838. */
  81839. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  81840. /**
  81841. * The parent glTF node.
  81842. */
  81843. parent?: INode;
  81844. /** @hidden */
  81845. _babylonTransformNode?: TransformNode;
  81846. /** @hidden */
  81847. _primitiveBabylonMeshes?: AbstractMesh[];
  81848. /** @hidden */
  81849. _babylonBones?: Bone[];
  81850. /** @hidden */
  81851. _numMorphTargets?: number;
  81852. }
  81853. /** @hidden */
  81854. export interface _ISamplerData {
  81855. noMipMaps: boolean;
  81856. samplingMode: number;
  81857. wrapU: number;
  81858. wrapV: number;
  81859. }
  81860. /**
  81861. * Loader interface with additional members.
  81862. */
  81863. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  81864. /** @hidden */
  81865. _data?: _ISamplerData;
  81866. }
  81867. /**
  81868. * Loader interface with additional members.
  81869. */
  81870. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  81871. }
  81872. /**
  81873. * Loader interface with additional members.
  81874. */
  81875. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  81876. /** @hidden */
  81877. _data?: {
  81878. babylonSkeleton: Skeleton;
  81879. promise: Promise<void>;
  81880. };
  81881. }
  81882. /**
  81883. * Loader interface with additional members.
  81884. */
  81885. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  81886. }
  81887. /**
  81888. * Loader interface with additional members.
  81889. */
  81890. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  81891. }
  81892. /**
  81893. * Loader interface with additional members.
  81894. */
  81895. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  81896. accessors?: IAccessor[];
  81897. animations?: IAnimation[];
  81898. buffers?: IBuffer[];
  81899. bufferViews?: IBufferView[];
  81900. cameras?: ICamera[];
  81901. images?: IImage[];
  81902. materials?: IMaterial[];
  81903. meshes?: IMesh[];
  81904. nodes?: INode[];
  81905. samplers?: ISampler[];
  81906. scenes?: IScene[];
  81907. skins?: ISkin[];
  81908. textures?: ITexture[];
  81909. }
  81910. }
  81911. declare module BABYLON.GLTF2 {
  81912. /**
  81913. * Interface for a glTF loader extension.
  81914. */
  81915. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  81916. /**
  81917. * Called after the loader state changes to LOADING.
  81918. */
  81919. onLoading?(): void;
  81920. /**
  81921. * Called after the loader state changes to READY.
  81922. */
  81923. onReady?(): void;
  81924. /**
  81925. * Define this method to modify the default behavior when loading scenes.
  81926. * @param context The context when loading the asset
  81927. * @param scene The glTF scene property
  81928. * @returns A promise that resolves when the load is complete or null if not handled
  81929. */
  81930. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  81931. /**
  81932. * Define this method to modify the default behavior when loading nodes.
  81933. * @param context The context when loading the asset
  81934. * @param node The glTF node property
  81935. * @param assign A function called synchronously after parsing the glTF properties
  81936. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  81937. */
  81938. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81939. /**
  81940. * Define this method to modify the default behavior when loading cameras.
  81941. * @param context The context when loading the asset
  81942. * @param camera The glTF camera property
  81943. * @param assign A function called synchronously after parsing the glTF properties
  81944. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  81945. */
  81946. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  81947. /**
  81948. * @hidden
  81949. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  81950. * @param context The context when loading the asset
  81951. * @param primitive The glTF mesh primitive property
  81952. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  81953. */
  81954. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  81955. /**
  81956. * @hidden
  81957. * Define this method to modify the default behavior when loading data for mesh primitives.
  81958. * @param context The context when loading the asset
  81959. * @param name The mesh name when loading the asset
  81960. * @param node The glTF node when loading the asset
  81961. * @param mesh The glTF mesh when loading the asset
  81962. * @param primitive The glTF mesh primitive property
  81963. * @param assign A function called synchronously after parsing the glTF properties
  81964. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  81965. */
  81966. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  81967. /**
  81968. * @hidden
  81969. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  81970. * @param context The context when loading the asset
  81971. * @param material The glTF material property
  81972. * @param assign A function called synchronously after parsing the glTF properties
  81973. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  81974. */
  81975. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  81976. /**
  81977. * Define this method to modify the default behavior when creating materials.
  81978. * @param context The context when loading the asset
  81979. * @param material The glTF material property
  81980. * @param babylonDrawMode The draw mode for the Babylon material
  81981. * @returns The Babylon material or null if not handled
  81982. */
  81983. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  81984. /**
  81985. * Define this method to modify the default behavior when loading material properties.
  81986. * @param context The context when loading the asset
  81987. * @param material The glTF material property
  81988. * @param babylonMaterial The Babylon material
  81989. * @returns A promise that resolves when the load is complete or null if not handled
  81990. */
  81991. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81992. /**
  81993. * Define this method to modify the default behavior when loading texture infos.
  81994. * @param context The context when loading the asset
  81995. * @param textureInfo The glTF texture info property
  81996. * @param assign A function called synchronously after parsing the glTF properties
  81997. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  81998. */
  81999. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82000. /**
  82001. * @hidden
  82002. * Define this method to modify the default behavior when loading textures.
  82003. * @param context The context when loading the asset
  82004. * @param texture The glTF texture property
  82005. * @param assign A function called synchronously after parsing the glTF properties
  82006. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  82007. */
  82008. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82009. /**
  82010. * Define this method to modify the default behavior when loading animations.
  82011. * @param context The context when loading the asset
  82012. * @param animation The glTF animation property
  82013. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  82014. */
  82015. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  82016. /**
  82017. * @hidden
  82018. * Define this method to modify the default behavior when loading skins.
  82019. * @param context The context when loading the asset
  82020. * @param node The glTF node property
  82021. * @param skin The glTF skin property
  82022. * @returns A promise that resolves when the load is complete or null if not handled
  82023. */
  82024. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  82025. /**
  82026. * @hidden
  82027. * Define this method to modify the default behavior when loading uris.
  82028. * @param context The context when loading the asset
  82029. * @param property The glTF property associated with the uri
  82030. * @param uri The uri to load
  82031. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  82032. */
  82033. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  82034. /**
  82035. * Define this method to modify the default behavior when loading buffer views.
  82036. * @param context The context when loading the asset
  82037. * @param bufferView The glTF buffer view property
  82038. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  82039. */
  82040. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  82041. /**
  82042. * Define this method to modify the default behavior when loading buffers.
  82043. * @param context The context when loading the asset
  82044. * @param buffer The glTF buffer property
  82045. * @param byteOffset The byte offset to load
  82046. * @param byteLength The byte length to load
  82047. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  82048. */
  82049. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  82050. }
  82051. }
  82052. declare module BABYLON.GLTF2 {
  82053. /**
  82054. * Helper class for working with arrays when loading the glTF asset
  82055. */
  82056. export class ArrayItem {
  82057. /**
  82058. * Gets an item from the given array.
  82059. * @param context The context when loading the asset
  82060. * @param array The array to get the item from
  82061. * @param index The index to the array
  82062. * @returns The array item
  82063. */
  82064. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  82065. /**
  82066. * Assign an `index` field to each item of the given array.
  82067. * @param array The array of items
  82068. */
  82069. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  82070. }
  82071. /**
  82072. * The glTF 2.0 loader
  82073. */
  82074. export class GLTFLoader implements IGLTFLoader {
  82075. /** @hidden */
  82076. _completePromises: Promise<any>[];
  82077. /** @hidden */
  82078. _forAssetContainer: boolean;
  82079. /** Storage */
  82080. _babylonLights: Light[];
  82081. /** @hidden */
  82082. _disableInstancedMesh: number;
  82083. private _disposed;
  82084. private _parent;
  82085. private _state;
  82086. private _extensions;
  82087. private _rootUrl;
  82088. private _fileName;
  82089. private _uniqueRootUrl;
  82090. private _gltf;
  82091. private _bin;
  82092. private _babylonScene;
  82093. private _rootBabylonMesh;
  82094. private _defaultBabylonMaterialData;
  82095. private static _RegisteredExtensions;
  82096. /**
  82097. * The default glTF sampler.
  82098. */
  82099. static readonly DefaultSampler: ISampler;
  82100. /**
  82101. * Registers a loader extension.
  82102. * @param name The name of the loader extension.
  82103. * @param factory The factory function that creates the loader extension.
  82104. */
  82105. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  82106. /**
  82107. * Unregisters a loader extension.
  82108. * @param name The name of the loader extension.
  82109. * @returns A boolean indicating whether the extension has been unregistered
  82110. */
  82111. static UnregisterExtension(name: string): boolean;
  82112. /**
  82113. * The loader state.
  82114. */
  82115. get state(): Nullable<GLTFLoaderState>;
  82116. /**
  82117. * The object that represents the glTF JSON.
  82118. */
  82119. get gltf(): IGLTF;
  82120. /**
  82121. * The BIN chunk of a binary glTF.
  82122. */
  82123. get bin(): Nullable<IDataBuffer>;
  82124. /**
  82125. * The parent file loader.
  82126. */
  82127. get parent(): GLTFFileLoader;
  82128. /**
  82129. * The Babylon scene when loading the asset.
  82130. */
  82131. get babylonScene(): Scene;
  82132. /**
  82133. * The root Babylon mesh when loading the asset.
  82134. */
  82135. get rootBabylonMesh(): Mesh;
  82136. /** @hidden */
  82137. constructor(parent: GLTFFileLoader);
  82138. /** @hidden */
  82139. dispose(): void;
  82140. /** @hidden */
  82141. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  82142. /** @hidden */
  82143. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  82144. private _loadAsync;
  82145. private _loadData;
  82146. private _setupData;
  82147. private _loadExtensions;
  82148. private _checkExtensions;
  82149. private _setState;
  82150. private _createRootNode;
  82151. /**
  82152. * Loads a glTF scene.
  82153. * @param context The context when loading the asset
  82154. * @param scene The glTF scene property
  82155. * @returns A promise that resolves when the load is complete
  82156. */
  82157. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  82158. private _forEachPrimitive;
  82159. private _getMeshes;
  82160. private _getTransformNodes;
  82161. private _getSkeletons;
  82162. private _getAnimationGroups;
  82163. private _startAnimations;
  82164. /**
  82165. * Loads a glTF node.
  82166. * @param context The context when loading the asset
  82167. * @param node The glTF node property
  82168. * @param assign A function called synchronously after parsing the glTF properties
  82169. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  82170. */
  82171. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  82172. private _loadMeshAsync;
  82173. /**
  82174. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  82175. * @param context The context when loading the asset
  82176. * @param name The mesh name when loading the asset
  82177. * @param node The glTF node when loading the asset
  82178. * @param mesh The glTF mesh when loading the asset
  82179. * @param primitive The glTF mesh primitive property
  82180. * @param assign A function called synchronously after parsing the glTF properties
  82181. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  82182. */
  82183. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  82184. private _loadVertexDataAsync;
  82185. private _createMorphTargets;
  82186. private _loadMorphTargetsAsync;
  82187. private _loadMorphTargetVertexDataAsync;
  82188. private static _LoadTransform;
  82189. private _loadSkinAsync;
  82190. private _loadBones;
  82191. private _loadBone;
  82192. private _loadSkinInverseBindMatricesDataAsync;
  82193. private _updateBoneMatrices;
  82194. private _getNodeMatrix;
  82195. /**
  82196. * Loads a glTF camera.
  82197. * @param context The context when loading the asset
  82198. * @param camera The glTF camera property
  82199. * @param assign A function called synchronously after parsing the glTF properties
  82200. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  82201. */
  82202. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  82203. private _loadAnimationsAsync;
  82204. /**
  82205. * Loads a glTF animation.
  82206. * @param context The context when loading the asset
  82207. * @param animation The glTF animation property
  82208. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  82209. */
  82210. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  82211. /**
  82212. * @hidden Loads a glTF animation channel.
  82213. * @param context The context when loading the asset
  82214. * @param animationContext The context of the animation when loading the asset
  82215. * @param animation The glTF animation property
  82216. * @param channel The glTF animation channel property
  82217. * @param babylonAnimationGroup The babylon animation group property
  82218. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  82219. * @returns A void promise when the channel load is complete
  82220. */
  82221. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  82222. private _loadAnimationSamplerAsync;
  82223. private _loadBufferAsync;
  82224. /**
  82225. * Loads a glTF buffer view.
  82226. * @param context The context when loading the asset
  82227. * @param bufferView The glTF buffer view property
  82228. * @returns A promise that resolves with the loaded data when the load is complete
  82229. */
  82230. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  82231. private _loadAccessorAsync;
  82232. /** @hidden */
  82233. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  82234. private _loadIndicesAccessorAsync;
  82235. private _loadVertexBufferViewAsync;
  82236. private _loadVertexAccessorAsync;
  82237. private _loadMaterialMetallicRoughnessPropertiesAsync;
  82238. /** @hidden */
  82239. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  82240. private _createDefaultMaterial;
  82241. /**
  82242. * Creates a Babylon material from a glTF material.
  82243. * @param context The context when loading the asset
  82244. * @param material The glTF material property
  82245. * @param babylonDrawMode The draw mode for the Babylon material
  82246. * @returns The Babylon material
  82247. */
  82248. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  82249. /**
  82250. * Loads properties from a glTF material into a Babylon material.
  82251. * @param context The context when loading the asset
  82252. * @param material The glTF material property
  82253. * @param babylonMaterial The Babylon material
  82254. * @returns A promise that resolves when the load is complete
  82255. */
  82256. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  82257. /**
  82258. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  82259. * @param context The context when loading the asset
  82260. * @param material The glTF material property
  82261. * @param babylonMaterial The Babylon material
  82262. * @returns A promise that resolves when the load is complete
  82263. */
  82264. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  82265. /**
  82266. * Loads the alpha properties from a glTF material into a Babylon material.
  82267. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  82268. * @param context The context when loading the asset
  82269. * @param material The glTF material property
  82270. * @param babylonMaterial The Babylon material
  82271. */
  82272. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  82273. /**
  82274. * Loads a glTF texture info.
  82275. * @param context The context when loading the asset
  82276. * @param textureInfo The glTF texture info property
  82277. * @param assign A function called synchronously after parsing the glTF properties
  82278. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  82279. */
  82280. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  82281. /** @hidden */
  82282. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  82283. /** @hidden */
  82284. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  82285. private _loadSampler;
  82286. /**
  82287. * Loads a glTF image.
  82288. * @param context The context when loading the asset
  82289. * @param image The glTF image property
  82290. * @returns A promise that resolves with the loaded data when the load is complete
  82291. */
  82292. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  82293. /**
  82294. * Loads a glTF uri.
  82295. * @param context The context when loading the asset
  82296. * @param property The glTF property associated with the uri
  82297. * @param uri The base64 or relative uri
  82298. * @returns A promise that resolves with the loaded data when the load is complete
  82299. */
  82300. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  82301. /**
  82302. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  82303. * @param babylonObject the Babylon object with metadata
  82304. * @param pointer the JSON pointer
  82305. */
  82306. static AddPointerMetadata(babylonObject: {
  82307. metadata: any;
  82308. }, pointer: string): void;
  82309. private static _GetTextureWrapMode;
  82310. private static _GetTextureSamplingMode;
  82311. private static _GetTypedArrayConstructor;
  82312. private static _GetTypedArray;
  82313. private static _GetNumComponents;
  82314. private static _ValidateUri;
  82315. /** @hidden */
  82316. static _GetDrawMode(context: string, mode: number | undefined): number;
  82317. private _compileMaterialsAsync;
  82318. private _compileShadowGeneratorsAsync;
  82319. private _forEachExtensions;
  82320. private _applyExtensions;
  82321. private _extensionsOnLoading;
  82322. private _extensionsOnReady;
  82323. private _extensionsLoadSceneAsync;
  82324. private _extensionsLoadNodeAsync;
  82325. private _extensionsLoadCameraAsync;
  82326. private _extensionsLoadVertexDataAsync;
  82327. private _extensionsLoadMeshPrimitiveAsync;
  82328. private _extensionsLoadMaterialAsync;
  82329. private _extensionsCreateMaterial;
  82330. private _extensionsLoadMaterialPropertiesAsync;
  82331. private _extensionsLoadTextureInfoAsync;
  82332. private _extensionsLoadTextureAsync;
  82333. private _extensionsLoadAnimationAsync;
  82334. private _extensionsLoadSkinAsync;
  82335. private _extensionsLoadUriAsync;
  82336. private _extensionsLoadBufferViewAsync;
  82337. private _extensionsLoadBufferAsync;
  82338. /**
  82339. * Helper method called by a loader extension to load an glTF extension.
  82340. * @param context The context when loading the asset
  82341. * @param property The glTF property to load the extension from
  82342. * @param extensionName The name of the extension to load
  82343. * @param actionAsync The action to run
  82344. * @returns The promise returned by actionAsync or null if the extension does not exist
  82345. */
  82346. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  82347. /**
  82348. * Helper method called by a loader extension to load a glTF extra.
  82349. * @param context The context when loading the asset
  82350. * @param property The glTF property to load the extra from
  82351. * @param extensionName The name of the extension to load
  82352. * @param actionAsync The action to run
  82353. * @returns The promise returned by actionAsync or null if the extra does not exist
  82354. */
  82355. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  82356. /**
  82357. * Checks for presence of an extension.
  82358. * @param name The name of the extension to check
  82359. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  82360. */
  82361. isExtensionUsed(name: string): boolean;
  82362. /**
  82363. * Increments the indentation level and logs a message.
  82364. * @param message The message to log
  82365. */
  82366. logOpen(message: string): void;
  82367. /**
  82368. * Decrements the indentation level.
  82369. */
  82370. logClose(): void;
  82371. /**
  82372. * Logs a message
  82373. * @param message The message to log
  82374. */
  82375. log(message: string): void;
  82376. /**
  82377. * Starts a performance counter.
  82378. * @param counterName The name of the performance counter
  82379. */
  82380. startPerformanceCounter(counterName: string): void;
  82381. /**
  82382. * Ends a performance counter.
  82383. * @param counterName The name of the performance counter
  82384. */
  82385. endPerformanceCounter(counterName: string): void;
  82386. }
  82387. }
  82388. declare module BABYLON.GLTF2.Loader.Extensions {
  82389. /** @hidden */
  82390. interface IEXTLightsImageBased_LightImageBased {
  82391. _babylonTexture?: BaseTexture;
  82392. _loaded?: Promise<void>;
  82393. }
  82394. /**
  82395. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  82396. */
  82397. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  82398. /**
  82399. * The name of this extension.
  82400. */
  82401. readonly name: string;
  82402. /**
  82403. * Defines whether this extension is enabled.
  82404. */
  82405. enabled: boolean;
  82406. private _loader;
  82407. private _lights?;
  82408. /** @hidden */
  82409. constructor(loader: GLTFLoader);
  82410. /** @hidden */
  82411. dispose(): void;
  82412. /** @hidden */
  82413. onLoading(): void;
  82414. /** @hidden */
  82415. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  82416. private _loadLightAsync;
  82417. }
  82418. }
  82419. declare module BABYLON.GLTF2.Loader.Extensions {
  82420. /**
  82421. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  82422. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  82423. * !!! Experimental Extension Subject to Changes !!!
  82424. */
  82425. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  82426. /**
  82427. * The name of this extension.
  82428. */
  82429. readonly name: string;
  82430. /**
  82431. * Defines whether this extension is enabled.
  82432. */
  82433. enabled: boolean;
  82434. private _loader;
  82435. /** @hidden */
  82436. constructor(loader: GLTFLoader);
  82437. /** @hidden */
  82438. dispose(): void;
  82439. /** @hidden */
  82440. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82441. }
  82442. }
  82443. declare module BABYLON.GLTF2.Loader.Extensions {
  82444. /**
  82445. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  82446. */
  82447. export class EXT_texture_webp implements IGLTFLoaderExtension {
  82448. /** The name of this extension. */
  82449. readonly name: string;
  82450. /** Defines whether this extension is enabled. */
  82451. enabled: boolean;
  82452. private _loader;
  82453. /** @hidden */
  82454. constructor(loader: GLTFLoader);
  82455. /** @hidden */
  82456. dispose(): void;
  82457. /** @hidden */
  82458. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82459. }
  82460. }
  82461. declare module BABYLON.GLTF2.Loader.Extensions {
  82462. /**
  82463. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  82464. */
  82465. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  82466. /**
  82467. * The name of this extension.
  82468. */
  82469. readonly name: string;
  82470. /**
  82471. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  82472. */
  82473. dracoCompression?: DracoCompression;
  82474. /**
  82475. * Defines whether this extension is enabled.
  82476. */
  82477. enabled: boolean;
  82478. private _loader;
  82479. /** @hidden */
  82480. constructor(loader: GLTFLoader);
  82481. /** @hidden */
  82482. dispose(): void;
  82483. /** @hidden */
  82484. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  82485. }
  82486. }
  82487. declare module BABYLON.GLTF2.Loader.Extensions {
  82488. /**
  82489. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  82490. */
  82491. export class KHR_lights implements IGLTFLoaderExtension {
  82492. /**
  82493. * The name of this extension.
  82494. */
  82495. readonly name: string;
  82496. /**
  82497. * Defines whether this extension is enabled.
  82498. */
  82499. enabled: boolean;
  82500. private _loader;
  82501. private _lights?;
  82502. /** @hidden */
  82503. constructor(loader: GLTFLoader);
  82504. /** @hidden */
  82505. dispose(): void;
  82506. /** @hidden */
  82507. onLoading(): void;
  82508. /** @hidden */
  82509. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82510. }
  82511. }
  82512. declare module BABYLON.GLTF2.Loader.Extensions {
  82513. /**
  82514. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  82515. */
  82516. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  82517. /**
  82518. * The name of this extension.
  82519. */
  82520. readonly name: string;
  82521. /**
  82522. * Defines whether this extension is enabled.
  82523. */
  82524. enabled: boolean;
  82525. /**
  82526. * Defines a number that determines the order the extensions are applied.
  82527. */
  82528. order: number;
  82529. private _loader;
  82530. /** @hidden */
  82531. constructor(loader: GLTFLoader);
  82532. /** @hidden */
  82533. dispose(): void;
  82534. /** @hidden */
  82535. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82536. private _loadSpecularGlossinessPropertiesAsync;
  82537. }
  82538. }
  82539. declare module BABYLON.GLTF2.Loader.Extensions {
  82540. /**
  82541. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  82542. */
  82543. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  82544. /**
  82545. * The name of this extension.
  82546. */
  82547. readonly name: string;
  82548. /**
  82549. * Defines whether this extension is enabled.
  82550. */
  82551. enabled: boolean;
  82552. /**
  82553. * Defines a number that determines the order the extensions are applied.
  82554. */
  82555. order: number;
  82556. private _loader;
  82557. /** @hidden */
  82558. constructor(loader: GLTFLoader);
  82559. /** @hidden */
  82560. dispose(): void;
  82561. /** @hidden */
  82562. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82563. private _loadUnlitPropertiesAsync;
  82564. }
  82565. }
  82566. declare module BABYLON.GLTF2.Loader.Extensions {
  82567. /**
  82568. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  82569. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  82570. * !!! Experimental Extension Subject to Changes !!!
  82571. */
  82572. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  82573. /**
  82574. * The name of this extension.
  82575. */
  82576. readonly name: string;
  82577. /**
  82578. * Defines whether this extension is enabled.
  82579. */
  82580. enabled: boolean;
  82581. /**
  82582. * Defines a number that determines the order the extensions are applied.
  82583. */
  82584. order: number;
  82585. private _loader;
  82586. /** @hidden */
  82587. constructor(loader: GLTFLoader);
  82588. /** @hidden */
  82589. dispose(): void;
  82590. /** @hidden */
  82591. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82592. private _loadClearCoatPropertiesAsync;
  82593. }
  82594. }
  82595. declare module BABYLON.GLTF2.Loader.Extensions {
  82596. /**
  82597. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  82598. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  82599. * !!! Experimental Extension Subject to Changes !!!
  82600. */
  82601. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  82602. /**
  82603. * The name of this extension.
  82604. */
  82605. readonly name: string;
  82606. /**
  82607. * Defines whether this extension is enabled.
  82608. */
  82609. enabled: boolean;
  82610. /**
  82611. * Defines a number that determines the order the extensions are applied.
  82612. */
  82613. order: number;
  82614. private _loader;
  82615. /** @hidden */
  82616. constructor(loader: GLTFLoader);
  82617. /** @hidden */
  82618. dispose(): void;
  82619. /** @hidden */
  82620. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82621. private _loadSheenPropertiesAsync;
  82622. }
  82623. }
  82624. declare module BABYLON.GLTF2.Loader.Extensions {
  82625. /**
  82626. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  82627. * !!! Experimental Extension Subject to Changes !!!
  82628. */
  82629. export class KHR_materials_specular implements IGLTFLoaderExtension {
  82630. /**
  82631. * The name of this extension.
  82632. */
  82633. readonly name: string;
  82634. /**
  82635. * Defines whether this extension is enabled.
  82636. */
  82637. enabled: boolean;
  82638. /**
  82639. * Defines a number that determines the order the extensions are applied.
  82640. */
  82641. order: number;
  82642. private _loader;
  82643. /** @hidden */
  82644. constructor(loader: GLTFLoader);
  82645. /** @hidden */
  82646. dispose(): void;
  82647. /** @hidden */
  82648. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82649. private _loadSpecularPropertiesAsync;
  82650. }
  82651. }
  82652. declare module BABYLON.GLTF2.Loader.Extensions {
  82653. /**
  82654. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  82655. * !!! Experimental Extension Subject to Changes !!!
  82656. */
  82657. export class KHR_materials_ior implements IGLTFLoaderExtension {
  82658. /**
  82659. * Default ior Value from the spec.
  82660. */
  82661. private static readonly _DEFAULT_IOR;
  82662. /**
  82663. * The name of this extension.
  82664. */
  82665. readonly name: string;
  82666. /**
  82667. * Defines whether this extension is enabled.
  82668. */
  82669. enabled: boolean;
  82670. /**
  82671. * Defines a number that determines the order the extensions are applied.
  82672. */
  82673. order: number;
  82674. private _loader;
  82675. /** @hidden */
  82676. constructor(loader: GLTFLoader);
  82677. /** @hidden */
  82678. dispose(): void;
  82679. /** @hidden */
  82680. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82681. private _loadIorPropertiesAsync;
  82682. }
  82683. }
  82684. declare module BABYLON.GLTF2.Loader.Extensions {
  82685. /**
  82686. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  82687. * !!! Experimental Extension Subject to Changes !!!
  82688. */
  82689. export class KHR_materials_variants implements IGLTFLoaderExtension {
  82690. /**
  82691. * The name of this extension.
  82692. */
  82693. readonly name: string;
  82694. /**
  82695. * Defines whether this extension is enabled.
  82696. */
  82697. enabled: boolean;
  82698. private _loader;
  82699. private _variants?;
  82700. /** @hidden */
  82701. constructor(loader: GLTFLoader);
  82702. /** @hidden */
  82703. dispose(): void;
  82704. /**
  82705. * Gets the list of available variant names for this asset.
  82706. * @param rootMesh The glTF root mesh
  82707. * @returns the list of all the variant names for this model
  82708. */
  82709. static GetAvailableVariants(rootMesh: Mesh): string[];
  82710. /**
  82711. * Gets the list of available variant names for this asset.
  82712. * @param rootMesh The glTF root mesh
  82713. * @returns the list of all the variant names for this model
  82714. */
  82715. getAvailableVariants(rootMesh: Mesh): string[];
  82716. /**
  82717. * Select a variant given a variant name or a list of variant names.
  82718. * @param rootMesh The glTF root mesh
  82719. * @param variantName The variant name(s) to select.
  82720. */
  82721. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  82722. /**
  82723. * Select a variant given a variant name or a list of variant names.
  82724. * @param rootMesh The glTF root mesh
  82725. * @param variantName The variant name(s) to select.
  82726. */
  82727. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  82728. /**
  82729. * Reset back to the original before selecting a variant.
  82730. * @param rootMesh The glTF root mesh
  82731. */
  82732. static Reset(rootMesh: Mesh): void;
  82733. /**
  82734. * Reset back to the original before selecting a variant.
  82735. * @param rootMesh The glTF root mesh
  82736. */
  82737. reset(rootMesh: Mesh): void;
  82738. /**
  82739. * Gets the last selected variant name(s) or null if original.
  82740. * @param rootMesh The glTF root mesh
  82741. * @returns The selected variant name(s).
  82742. */
  82743. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  82744. /**
  82745. * Gets the last selected variant name(s) or null if original.
  82746. * @param rootMesh The glTF root mesh
  82747. * @returns The selected variant name(s).
  82748. */
  82749. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  82750. private static _GetExtensionMetadata;
  82751. /** @hidden */
  82752. onLoading(): void;
  82753. /** @hidden */
  82754. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  82755. }
  82756. }
  82757. declare module BABYLON.GLTF2.Loader.Extensions {
  82758. /**
  82759. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  82760. * !!! Experimental Extension Subject to Changes !!!
  82761. */
  82762. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  82763. /**
  82764. * The name of this extension.
  82765. */
  82766. readonly name: string;
  82767. /**
  82768. * Defines whether this extension is enabled.
  82769. */
  82770. enabled: boolean;
  82771. /**
  82772. * Defines a number that determines the order the extensions are applied.
  82773. */
  82774. order: number;
  82775. private _loader;
  82776. /** @hidden */
  82777. constructor(loader: GLTFLoader);
  82778. /** @hidden */
  82779. dispose(): void;
  82780. /** @hidden */
  82781. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82782. private _loadTransparentPropertiesAsync;
  82783. }
  82784. }
  82785. declare module BABYLON.GLTF2.Loader.Extensions {
  82786. /**
  82787. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  82788. */
  82789. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  82790. /**
  82791. * The name of this extension.
  82792. */
  82793. readonly name: string;
  82794. /**
  82795. * Defines whether this extension is enabled.
  82796. */
  82797. enabled: boolean;
  82798. /** @hidden */
  82799. constructor(loader: GLTFLoader);
  82800. /** @hidden */
  82801. dispose(): void;
  82802. }
  82803. }
  82804. declare module BABYLON.GLTF2.Loader.Extensions {
  82805. /**
  82806. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  82807. * !!! Experimental Extension Subject to Changes !!!
  82808. */
  82809. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  82810. /** The name of this extension. */
  82811. readonly name: string;
  82812. /** Defines whether this extension is enabled. */
  82813. enabled: boolean;
  82814. private _loader;
  82815. /** @hidden */
  82816. constructor(loader: GLTFLoader);
  82817. /** @hidden */
  82818. dispose(): void;
  82819. /** @hidden */
  82820. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82821. }
  82822. }
  82823. declare module BABYLON.GLTF2.Loader.Extensions {
  82824. /**
  82825. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  82826. */
  82827. export class KHR_texture_transform implements IGLTFLoaderExtension {
  82828. /**
  82829. * The name of this extension.
  82830. */
  82831. readonly name: string;
  82832. /**
  82833. * Defines whether this extension is enabled.
  82834. */
  82835. enabled: boolean;
  82836. private _loader;
  82837. /** @hidden */
  82838. constructor(loader: GLTFLoader);
  82839. /** @hidden */
  82840. dispose(): void;
  82841. /** @hidden */
  82842. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82843. }
  82844. }
  82845. declare module BABYLON.GLTF2.Loader.Extensions {
  82846. /**
  82847. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  82848. * !!! Experimental Extension Subject to Changes !!!
  82849. */
  82850. export class KHR_xmp implements IGLTFLoaderExtension {
  82851. /**
  82852. * The name of this extension.
  82853. */
  82854. readonly name: string;
  82855. /**
  82856. * Defines whether this extension is enabled.
  82857. */
  82858. enabled: boolean;
  82859. /**
  82860. * Defines a number that determines the order the extensions are applied.
  82861. */
  82862. order: number;
  82863. private _loader;
  82864. /** @hidden */
  82865. constructor(loader: GLTFLoader);
  82866. /** @hidden */
  82867. dispose(): void;
  82868. /**
  82869. * Called after the loader state changes to LOADING.
  82870. */
  82871. onLoading(): void;
  82872. }
  82873. }
  82874. declare module BABYLON.GLTF2.Loader.Extensions {
  82875. /**
  82876. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  82877. */
  82878. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  82879. /**
  82880. * The name of this extension.
  82881. */
  82882. readonly name: string;
  82883. /**
  82884. * Defines whether this extension is enabled.
  82885. */
  82886. enabled: boolean;
  82887. private _loader;
  82888. private _clips;
  82889. private _emitters;
  82890. /** @hidden */
  82891. constructor(loader: GLTFLoader);
  82892. /** @hidden */
  82893. dispose(): void;
  82894. /** @hidden */
  82895. onLoading(): void;
  82896. /** @hidden */
  82897. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  82898. /** @hidden */
  82899. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82900. /** @hidden */
  82901. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  82902. private _loadClipAsync;
  82903. private _loadEmitterAsync;
  82904. private _getEventAction;
  82905. private _loadAnimationEventAsync;
  82906. }
  82907. }
  82908. declare module BABYLON.GLTF2.Loader.Extensions {
  82909. /**
  82910. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  82911. */
  82912. export class MSFT_lod implements IGLTFLoaderExtension {
  82913. /**
  82914. * The name of this extension.
  82915. */
  82916. readonly name: string;
  82917. /**
  82918. * Defines whether this extension is enabled.
  82919. */
  82920. enabled: boolean;
  82921. /**
  82922. * Defines a number that determines the order the extensions are applied.
  82923. */
  82924. order: number;
  82925. /**
  82926. * Maximum number of LODs to load, starting from the lowest LOD.
  82927. */
  82928. maxLODsToLoad: number;
  82929. /**
  82930. * Observable raised when all node LODs of one level are loaded.
  82931. * The event data is the index of the loaded LOD starting from zero.
  82932. * Dispose the loader to cancel the loading of the next level of LODs.
  82933. */
  82934. onNodeLODsLoadedObservable: Observable<number>;
  82935. /**
  82936. * Observable raised when all material LODs of one level are loaded.
  82937. * The event data is the index of the loaded LOD starting from zero.
  82938. * Dispose the loader to cancel the loading of the next level of LODs.
  82939. */
  82940. onMaterialLODsLoadedObservable: Observable<number>;
  82941. private _loader;
  82942. private _bufferLODs;
  82943. private _nodeIndexLOD;
  82944. private _nodeSignalLODs;
  82945. private _nodePromiseLODs;
  82946. private _nodeBufferLODs;
  82947. private _materialIndexLOD;
  82948. private _materialSignalLODs;
  82949. private _materialPromiseLODs;
  82950. private _materialBufferLODs;
  82951. /** @hidden */
  82952. constructor(loader: GLTFLoader);
  82953. /** @hidden */
  82954. dispose(): void;
  82955. /** @hidden */
  82956. onReady(): void;
  82957. /** @hidden */
  82958. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  82959. /** @hidden */
  82960. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82961. /** @hidden */
  82962. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  82963. /** @hidden */
  82964. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  82965. /** @hidden */
  82966. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  82967. private _loadBufferLOD;
  82968. /**
  82969. * Gets an array of LOD properties from lowest to highest.
  82970. */
  82971. private _getLODs;
  82972. private _disposeTransformNode;
  82973. private _disposeMaterials;
  82974. }
  82975. }
  82976. declare module BABYLON.GLTF2.Loader.Extensions {
  82977. /** @hidden */
  82978. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  82979. readonly name: string;
  82980. enabled: boolean;
  82981. private _loader;
  82982. constructor(loader: GLTFLoader);
  82983. dispose(): void;
  82984. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82985. }
  82986. }
  82987. declare module BABYLON.GLTF2.Loader.Extensions {
  82988. /** @hidden */
  82989. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  82990. readonly name: string;
  82991. enabled: boolean;
  82992. private _loader;
  82993. constructor(loader: GLTFLoader);
  82994. dispose(): void;
  82995. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82996. }
  82997. }
  82998. declare module BABYLON.GLTF2.Loader.Extensions {
  82999. /**
  83000. * Store glTF extras (if present) in BJS objects' metadata
  83001. */
  83002. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  83003. /**
  83004. * The name of this extension.
  83005. */
  83006. readonly name: string;
  83007. /**
  83008. * Defines whether this extension is enabled.
  83009. */
  83010. enabled: boolean;
  83011. private _loader;
  83012. private _assignExtras;
  83013. /** @hidden */
  83014. constructor(loader: GLTFLoader);
  83015. /** @hidden */
  83016. dispose(): void;
  83017. /** @hidden */
  83018. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83019. /** @hidden */
  83020. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  83021. /** @hidden */
  83022. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  83023. }
  83024. }
  83025. declare module BABYLON {
  83026. /**
  83027. * Class reading and parsing the MTL file bundled with the obj file.
  83028. */
  83029. export class MTLFileLoader {
  83030. /**
  83031. * Invert Y-Axis of referenced textures on load
  83032. */
  83033. static INVERT_TEXTURE_Y: boolean;
  83034. /**
  83035. * All material loaded from the mtl will be set here
  83036. */
  83037. materials: StandardMaterial[];
  83038. /**
  83039. * This function will read the mtl file and create each material described inside
  83040. * This function could be improve by adding :
  83041. * -some component missing (Ni, Tf...)
  83042. * -including the specific options available
  83043. *
  83044. * @param scene defines the scene the material will be created in
  83045. * @param data defines the mtl data to parse
  83046. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  83047. * @param forAssetContainer defines if the material should be registered in the scene
  83048. */
  83049. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  83050. /**
  83051. * Gets the texture for the material.
  83052. *
  83053. * If the material is imported from input file,
  83054. * We sanitize the url to ensure it takes the textre from aside the material.
  83055. *
  83056. * @param rootUrl The root url to load from
  83057. * @param value The value stored in the mtl
  83058. * @return The Texture
  83059. */
  83060. private static _getTexture;
  83061. }
  83062. }
  83063. declare module BABYLON {
  83064. /**
  83065. * Options for loading OBJ/MTL files
  83066. */
  83067. type MeshLoadOptions = {
  83068. /**
  83069. * Defines if UVs are optimized by default during load.
  83070. */
  83071. OptimizeWithUV: boolean;
  83072. /**
  83073. * Defines custom scaling of UV coordinates of loaded meshes.
  83074. */
  83075. UVScaling: Vector2;
  83076. /**
  83077. * Invert model on y-axis (does a model scaling inversion)
  83078. */
  83079. InvertY: boolean;
  83080. /**
  83081. * Invert Y-Axis of referenced textures on load
  83082. */
  83083. InvertTextureY: boolean;
  83084. /**
  83085. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  83086. */
  83087. ImportVertexColors: boolean;
  83088. /**
  83089. * Compute the normals for the model, even if normals are present in the file.
  83090. */
  83091. ComputeNormals: boolean;
  83092. /**
  83093. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  83094. */
  83095. SkipMaterials: boolean;
  83096. /**
  83097. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  83098. */
  83099. MaterialLoadingFailsSilently: boolean;
  83100. };
  83101. /**
  83102. * OBJ file type loader.
  83103. * This is a babylon scene loader plugin.
  83104. */
  83105. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  83106. /**
  83107. * Defines if UVs are optimized by default during load.
  83108. */
  83109. static OPTIMIZE_WITH_UV: boolean;
  83110. /**
  83111. * Invert model on y-axis (does a model scaling inversion)
  83112. */
  83113. static INVERT_Y: boolean;
  83114. /**
  83115. * Invert Y-Axis of referenced textures on load
  83116. */
  83117. static get INVERT_TEXTURE_Y(): boolean;
  83118. static set INVERT_TEXTURE_Y(value: boolean);
  83119. /**
  83120. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  83121. */
  83122. static IMPORT_VERTEX_COLORS: boolean;
  83123. /**
  83124. * Compute the normals for the model, even if normals are present in the file.
  83125. */
  83126. static COMPUTE_NORMALS: boolean;
  83127. /**
  83128. * Defines custom scaling of UV coordinates of loaded meshes.
  83129. */
  83130. static UV_SCALING: Vector2;
  83131. /**
  83132. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  83133. */
  83134. static SKIP_MATERIALS: boolean;
  83135. /**
  83136. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  83137. *
  83138. * Defaults to true for backwards compatibility.
  83139. */
  83140. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  83141. /**
  83142. * Defines the name of the plugin.
  83143. */
  83144. name: string;
  83145. /**
  83146. * Defines the extension the plugin is able to load.
  83147. */
  83148. extensions: string;
  83149. /** @hidden */
  83150. obj: RegExp;
  83151. /** @hidden */
  83152. group: RegExp;
  83153. /** @hidden */
  83154. mtllib: RegExp;
  83155. /** @hidden */
  83156. usemtl: RegExp;
  83157. /** @hidden */
  83158. smooth: RegExp;
  83159. /** @hidden */
  83160. vertexPattern: RegExp;
  83161. /** @hidden */
  83162. normalPattern: RegExp;
  83163. /** @hidden */
  83164. uvPattern: RegExp;
  83165. /** @hidden */
  83166. facePattern1: RegExp;
  83167. /** @hidden */
  83168. facePattern2: RegExp;
  83169. /** @hidden */
  83170. facePattern3: RegExp;
  83171. /** @hidden */
  83172. facePattern4: RegExp;
  83173. /** @hidden */
  83174. facePattern5: RegExp;
  83175. private _forAssetContainer;
  83176. private _meshLoadOptions;
  83177. /**
  83178. * Creates loader for .OBJ files
  83179. *
  83180. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  83181. */
  83182. constructor(meshLoadOptions?: MeshLoadOptions);
  83183. private static get currentMeshLoadOptions();
  83184. /**
  83185. * Calls synchronously the MTL file attached to this obj.
  83186. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  83187. * Without this function materials are not displayed in the first frame (but displayed after).
  83188. * In consequence it is impossible to get material information in your HTML file
  83189. *
  83190. * @param url The URL of the MTL file
  83191. * @param rootUrl
  83192. * @param onSuccess Callback function to be called when the MTL file is loaded
  83193. * @private
  83194. */
  83195. private _loadMTL;
  83196. /**
  83197. * Instantiates a OBJ file loader plugin.
  83198. * @returns the created plugin
  83199. */
  83200. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  83201. /**
  83202. * If the data string can be loaded directly.
  83203. *
  83204. * @param data string containing the file data
  83205. * @returns if the data can be loaded directly
  83206. */
  83207. canDirectLoad(data: string): boolean;
  83208. /**
  83209. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  83210. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  83211. * @param scene the scene the meshes should be added to
  83212. * @param data the OBJ data to load
  83213. * @param rootUrl root url to load from
  83214. * @param onProgress event that fires when loading progress has occured
  83215. * @param fileName Defines the name of the file to load
  83216. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  83217. */
  83218. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  83219. meshes: AbstractMesh[];
  83220. particleSystems: IParticleSystem[];
  83221. skeletons: Skeleton[];
  83222. animationGroups: AnimationGroup[];
  83223. }>;
  83224. /**
  83225. * Imports all objects from the loaded OBJ data and adds them to the scene
  83226. * @param scene the scene the objects should be added to
  83227. * @param data the OBJ data to load
  83228. * @param rootUrl root url to load from
  83229. * @param onProgress event that fires when loading progress has occured
  83230. * @param fileName Defines the name of the file to load
  83231. * @returns a promise which completes when objects have been loaded to the scene
  83232. */
  83233. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  83234. /**
  83235. * Load into an asset container.
  83236. * @param scene The scene to load into
  83237. * @param data The data to import
  83238. * @param rootUrl The root url for scene and resources
  83239. * @param onProgress The callback when the load progresses
  83240. * @param fileName Defines the name of the file to load
  83241. * @returns The loaded asset container
  83242. */
  83243. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  83244. /**
  83245. * Read the OBJ file and create an Array of meshes.
  83246. * Each mesh contains all information given by the OBJ and the MTL file.
  83247. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  83248. *
  83249. * @param meshesNames
  83250. * @param scene Scene The scene where are displayed the data
  83251. * @param data String The content of the obj file
  83252. * @param rootUrl String The path to the folder
  83253. * @returns Array<AbstractMesh>
  83254. * @private
  83255. */
  83256. private _parseSolid;
  83257. }
  83258. }
  83259. declare module BABYLON {
  83260. /**
  83261. * STL file type loader.
  83262. * This is a babylon scene loader plugin.
  83263. */
  83264. export class STLFileLoader implements ISceneLoaderPlugin {
  83265. /** @hidden */
  83266. solidPattern: RegExp;
  83267. /** @hidden */
  83268. facetsPattern: RegExp;
  83269. /** @hidden */
  83270. normalPattern: RegExp;
  83271. /** @hidden */
  83272. vertexPattern: RegExp;
  83273. /**
  83274. * Defines the name of the plugin.
  83275. */
  83276. name: string;
  83277. /**
  83278. * Defines the extensions the stl loader is able to load.
  83279. * force data to come in as an ArrayBuffer
  83280. * we'll convert to string if it looks like it's an ASCII .stl
  83281. */
  83282. extensions: ISceneLoaderPluginExtensions;
  83283. /**
  83284. * Import meshes into a scene.
  83285. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  83286. * @param scene The scene to import into
  83287. * @param data The data to import
  83288. * @param rootUrl The root url for scene and resources
  83289. * @param meshes The meshes array to import into
  83290. * @param particleSystems The particle systems array to import into
  83291. * @param skeletons The skeletons array to import into
  83292. * @param onError The callback when import fails
  83293. * @returns True if successful or false otherwise
  83294. */
  83295. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  83296. /**
  83297. * Load into a scene.
  83298. * @param scene The scene to load into
  83299. * @param data The data to import
  83300. * @param rootUrl The root url for scene and resources
  83301. * @param onError The callback when import fails
  83302. * @returns true if successful or false otherwise
  83303. */
  83304. load(scene: Scene, data: any, rootUrl: string): boolean;
  83305. /**
  83306. * Load into an asset container.
  83307. * @param scene The scene to load into
  83308. * @param data The data to import
  83309. * @param rootUrl The root url for scene and resources
  83310. * @param onError The callback when import fails
  83311. * @returns The loaded asset container
  83312. */
  83313. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  83314. private _isBinary;
  83315. private _parseBinary;
  83316. private _parseASCII;
  83317. }
  83318. }
  83319. declare module BABYLON {
  83320. /**
  83321. * Class for generating OBJ data from a Babylon scene.
  83322. */
  83323. export class OBJExport {
  83324. /**
  83325. * Exports the geometry of a Mesh array in .OBJ file format (text)
  83326. * @param mesh defines the list of meshes to serialize
  83327. * @param materials defines if materials should be exported
  83328. * @param matlibname defines the name of the associated mtl file
  83329. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  83330. * @returns the OBJ content
  83331. */
  83332. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  83333. /**
  83334. * Exports the material(s) of a mesh in .MTL file format (text)
  83335. * @param mesh defines the mesh to extract the material from
  83336. * @returns the mtl content
  83337. */
  83338. static MTL(mesh: Mesh): string;
  83339. }
  83340. }
  83341. declare module BABYLON {
  83342. /** @hidden */
  83343. export var __IGLTFExporterExtension: number;
  83344. /**
  83345. * Interface for extending the exporter
  83346. * @hidden
  83347. */
  83348. export interface IGLTFExporterExtension {
  83349. /**
  83350. * The name of this extension
  83351. */
  83352. readonly name: string;
  83353. /**
  83354. * Defines whether this extension is enabled
  83355. */
  83356. enabled: boolean;
  83357. /**
  83358. * Defines whether this extension is required
  83359. */
  83360. required: boolean;
  83361. }
  83362. }
  83363. declare module BABYLON.GLTF2.Exporter {
  83364. /** @hidden */
  83365. export var __IGLTFExporterExtensionV2: number;
  83366. /**
  83367. * Interface for a glTF exporter extension
  83368. * @hidden
  83369. */
  83370. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  83371. /**
  83372. * Define this method to modify the default behavior before exporting a texture
  83373. * @param context The context when loading the asset
  83374. * @param babylonTexture The Babylon.js texture
  83375. * @param mimeType The mime-type of the generated image
  83376. * @returns A promise that resolves with the exported texture
  83377. */
  83378. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  83379. /**
  83380. * Define this method to get notified when a texture info is created
  83381. * @param context The context when loading the asset
  83382. * @param textureInfo The glTF texture info
  83383. * @param babylonTexture The Babylon.js texture
  83384. */
  83385. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  83386. /**
  83387. * Define this method to modify the default behavior when exporting texture info
  83388. * @param context The context when loading the asset
  83389. * @param meshPrimitive glTF mesh primitive
  83390. * @param babylonSubMesh Babylon submesh
  83391. * @param binaryWriter glTF serializer binary writer instance
  83392. * @returns nullable IMeshPrimitive promise
  83393. */
  83394. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  83395. /**
  83396. * Define this method to modify the default behavior when exporting a node
  83397. * @param context The context when exporting the node
  83398. * @param node glTF node
  83399. * @param babylonNode BabylonJS node
  83400. * @returns nullable INode promise
  83401. */
  83402. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  83403. [key: number]: number;
  83404. }): Promise<Nullable<INode>>;
  83405. /**
  83406. * Define this method to modify the default behavior when exporting a material
  83407. * @param material glTF material
  83408. * @param babylonMaterial BabylonJS material
  83409. * @returns nullable IMaterial promise
  83410. */
  83411. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  83412. /**
  83413. * Define this method to return additional textures to export from a material
  83414. * @param material glTF material
  83415. * @param babylonMaterial BabylonJS material
  83416. * @returns List of textures
  83417. */
  83418. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  83419. /** Gets a boolean indicating that this extension was used */
  83420. wasUsed: boolean;
  83421. /** Gets a boolean indicating that this extension is required for the file to work */
  83422. required: boolean;
  83423. /**
  83424. * Called after the exporter state changes to EXPORTING
  83425. */
  83426. onExporting?(): void;
  83427. }
  83428. }
  83429. declare module BABYLON.GLTF2.Exporter {
  83430. /**
  83431. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  83432. * @hidden
  83433. */
  83434. export class _GLTFMaterialExporter {
  83435. /**
  83436. * Represents the dielectric specular values for R, G and B
  83437. */
  83438. private static readonly _DielectricSpecular;
  83439. /**
  83440. * Allows the maximum specular power to be defined for material calculations
  83441. */
  83442. private static readonly _MaxSpecularPower;
  83443. /**
  83444. * Mapping to store textures
  83445. */
  83446. private _textureMap;
  83447. /**
  83448. * Numeric tolerance value
  83449. */
  83450. private static readonly _Epsilon;
  83451. /**
  83452. * Reference to the glTF Exporter
  83453. */
  83454. private _exporter;
  83455. constructor(exporter: _Exporter);
  83456. /**
  83457. * Specifies if two colors are approximately equal in value
  83458. * @param color1 first color to compare to
  83459. * @param color2 second color to compare to
  83460. * @param epsilon threshold value
  83461. */
  83462. private static FuzzyEquals;
  83463. /**
  83464. * Gets the materials from a Babylon scene and converts them to glTF materials
  83465. * @param scene babylonjs scene
  83466. * @param mimeType texture mime type
  83467. * @param images array of images
  83468. * @param textures array of textures
  83469. * @param materials array of materials
  83470. * @param imageData mapping of texture names to base64 textures
  83471. * @param hasTextureCoords specifies if texture coordinates are present on the material
  83472. */
  83473. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  83474. /**
  83475. * Makes a copy of the glTF material without the texture parameters
  83476. * @param originalMaterial original glTF material
  83477. * @returns glTF material without texture parameters
  83478. */
  83479. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  83480. /**
  83481. * Specifies if the material has any texture parameters present
  83482. * @param material glTF Material
  83483. * @returns boolean specifying if texture parameters are present
  83484. */
  83485. _hasTexturesPresent(material: IMaterial): boolean;
  83486. /**
  83487. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  83488. * @param babylonStandardMaterial
  83489. * @returns glTF Metallic Roughness Material representation
  83490. */
  83491. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  83492. /**
  83493. * Computes the metallic factor
  83494. * @param diffuse diffused value
  83495. * @param specular specular value
  83496. * @param oneMinusSpecularStrength one minus the specular strength
  83497. * @returns metallic value
  83498. */
  83499. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  83500. /**
  83501. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  83502. * @param glTFMaterial glTF material
  83503. * @param babylonMaterial Babylon material
  83504. */
  83505. private static _SetAlphaMode;
  83506. /**
  83507. * Converts a Babylon Standard Material to a glTF Material
  83508. * @param babylonStandardMaterial BJS Standard Material
  83509. * @param mimeType mime type to use for the textures
  83510. * @param images array of glTF image interfaces
  83511. * @param textures array of glTF texture interfaces
  83512. * @param materials array of glTF material interfaces
  83513. * @param imageData map of image file name to data
  83514. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83515. */
  83516. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  83517. private _finishMaterial;
  83518. /**
  83519. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  83520. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  83521. * @param mimeType mime type to use for the textures
  83522. * @param images array of glTF image interfaces
  83523. * @param textures array of glTF texture interfaces
  83524. * @param materials array of glTF material interfaces
  83525. * @param imageData map of image file name to data
  83526. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83527. */
  83528. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  83529. /**
  83530. * Converts an image typed array buffer to a base64 image
  83531. * @param buffer typed array buffer
  83532. * @param width width of the image
  83533. * @param height height of the image
  83534. * @param mimeType mimetype of the image
  83535. * @returns base64 image string
  83536. */
  83537. private _createBase64FromCanvasAsync;
  83538. /**
  83539. * Generates a white texture based on the specified width and height
  83540. * @param width width of the texture in pixels
  83541. * @param height height of the texture in pixels
  83542. * @param scene babylonjs scene
  83543. * @returns white texture
  83544. */
  83545. private _createWhiteTexture;
  83546. /**
  83547. * 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
  83548. * @param texture1 first texture to resize
  83549. * @param texture2 second texture to resize
  83550. * @param scene babylonjs scene
  83551. * @returns resized textures or null
  83552. */
  83553. private _resizeTexturesToSameDimensions;
  83554. /**
  83555. * Converts an array of pixels to a Float32Array
  83556. * Throws an error if the pixel format is not supported
  83557. * @param pixels - array buffer containing pixel values
  83558. * @returns Float32 of pixels
  83559. */
  83560. private _convertPixelArrayToFloat32;
  83561. /**
  83562. * Convert Specular Glossiness Textures to Metallic Roughness
  83563. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  83564. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  83565. * @param diffuseTexture texture used to store diffuse information
  83566. * @param specularGlossinessTexture texture used to store specular and glossiness information
  83567. * @param factors specular glossiness material factors
  83568. * @param mimeType the mime type to use for the texture
  83569. * @returns pbr metallic roughness interface or null
  83570. */
  83571. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  83572. /**
  83573. * Converts specular glossiness material properties to metallic roughness
  83574. * @param specularGlossiness interface with specular glossiness material properties
  83575. * @returns interface with metallic roughness material properties
  83576. */
  83577. private _convertSpecularGlossinessToMetallicRoughness;
  83578. /**
  83579. * Calculates the surface reflectance, independent of lighting conditions
  83580. * @param color Color source to calculate brightness from
  83581. * @returns number representing the perceived brightness, or zero if color is undefined
  83582. */
  83583. private _getPerceivedBrightness;
  83584. /**
  83585. * Returns the maximum color component value
  83586. * @param color
  83587. * @returns maximum color component value, or zero if color is null or undefined
  83588. */
  83589. private _getMaxComponent;
  83590. /**
  83591. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  83592. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  83593. * @param mimeType mime type to use for the textures
  83594. * @param images array of glTF image interfaces
  83595. * @param textures array of glTF texture interfaces
  83596. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  83597. * @param imageData map of image file name to data
  83598. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83599. * @returns glTF PBR Metallic Roughness factors
  83600. */
  83601. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  83602. private _getGLTFTextureSampler;
  83603. private _getGLTFTextureWrapMode;
  83604. private _getGLTFTextureWrapModesSampler;
  83605. /**
  83606. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  83607. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  83608. * @param mimeType mime type to use for the textures
  83609. * @param images array of glTF image interfaces
  83610. * @param textures array of glTF texture interfaces
  83611. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  83612. * @param imageData map of image file name to data
  83613. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83614. * @returns glTF PBR Metallic Roughness factors
  83615. */
  83616. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  83617. /**
  83618. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  83619. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  83620. * @param mimeType mime type to use for the textures
  83621. * @param images array of glTF image interfaces
  83622. * @param textures array of glTF texture interfaces
  83623. * @param materials array of glTF material interfaces
  83624. * @param imageData map of image file name to data
  83625. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83626. */
  83627. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  83628. private setMetallicRoughnessPbrMaterial;
  83629. private getPixelsFromTexture;
  83630. /**
  83631. * Extracts a texture from a Babylon texture into file data and glTF data
  83632. * @param babylonTexture Babylon texture to extract
  83633. * @param mimeType Mime Type of the babylonTexture
  83634. * @return glTF texture info, or null if the texture format is not supported
  83635. */
  83636. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  83637. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  83638. /**
  83639. * Builds a texture from base64 string
  83640. * @param base64Texture base64 texture string
  83641. * @param baseTextureName Name to use for the texture
  83642. * @param mimeType image mime type for the texture
  83643. * @param images array of images
  83644. * @param textures array of textures
  83645. * @param imageData map of image data
  83646. * @returns glTF texture info, or null if the texture format is not supported
  83647. */
  83648. private _getTextureInfoFromBase64;
  83649. }
  83650. }
  83651. declare module BABYLON {
  83652. /**
  83653. * Class for holding and downloading glTF file data
  83654. */
  83655. export class GLTFData {
  83656. /**
  83657. * Object which contains the file name as the key and its data as the value
  83658. */
  83659. glTFFiles: {
  83660. [fileName: string]: string | Blob;
  83661. };
  83662. /**
  83663. * Initializes the glTF file object
  83664. */
  83665. constructor();
  83666. /**
  83667. * Downloads the glTF data as files based on their names and data
  83668. */
  83669. downloadFiles(): void;
  83670. }
  83671. }
  83672. declare module BABYLON {
  83673. /**
  83674. * Holds a collection of exporter options and parameters
  83675. */
  83676. export interface IExportOptions {
  83677. /**
  83678. * Function which indicates whether a babylon node should be exported or not
  83679. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  83680. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  83681. */
  83682. shouldExportNode?(node: Node): boolean;
  83683. /**
  83684. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  83685. * @param metadata source metadata to read from
  83686. * @returns the data to store to glTF node extras
  83687. */
  83688. metadataSelector?(metadata: any): any;
  83689. /**
  83690. * The sample rate to bake animation curves
  83691. */
  83692. animationSampleRate?: number;
  83693. /**
  83694. * Begin serialization without waiting for the scene to be ready
  83695. */
  83696. exportWithoutWaitingForScene?: boolean;
  83697. /**
  83698. * Indicates if coordinate system swapping root nodes should be included in export
  83699. */
  83700. includeCoordinateSystemConversionNodes?: boolean;
  83701. }
  83702. /**
  83703. * Class for generating glTF data from a Babylon scene.
  83704. */
  83705. export class GLTF2Export {
  83706. /**
  83707. * Exports the geometry of the scene to .gltf file format asynchronously
  83708. * @param scene Babylon scene with scene hierarchy information
  83709. * @param filePrefix File prefix to use when generating the glTF file
  83710. * @param options Exporter options
  83711. * @returns Returns an object with a .gltf file and associates texture names
  83712. * as keys and their data and paths as values
  83713. */
  83714. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  83715. private static _PreExportAsync;
  83716. private static _PostExportAsync;
  83717. /**
  83718. * Exports the geometry of the scene to .glb file format asychronously
  83719. * @param scene Babylon scene with scene hierarchy information
  83720. * @param filePrefix File prefix to use when generating glb file
  83721. * @param options Exporter options
  83722. * @returns Returns an object with a .glb filename as key and data as value
  83723. */
  83724. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  83725. }
  83726. }
  83727. declare module BABYLON.GLTF2.Exporter {
  83728. /**
  83729. * @hidden
  83730. */
  83731. export class _GLTFUtilities {
  83732. /**
  83733. * Creates a buffer view based on the supplied arguments
  83734. * @param bufferIndex index value of the specified buffer
  83735. * @param byteOffset byte offset value
  83736. * @param byteLength byte length of the bufferView
  83737. * @param byteStride byte distance between conequential elements
  83738. * @param name name of the buffer view
  83739. * @returns bufferView for glTF
  83740. */
  83741. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  83742. /**
  83743. * Creates an accessor based on the supplied arguments
  83744. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  83745. * @param name The name of the accessor
  83746. * @param type The type of the accessor
  83747. * @param componentType The datatype of components in the attribute
  83748. * @param count The number of attributes referenced by this accessor
  83749. * @param byteOffset The offset relative to the start of the bufferView in bytes
  83750. * @param min Minimum value of each component in this attribute
  83751. * @param max Maximum value of each component in this attribute
  83752. * @returns accessor for glTF
  83753. */
  83754. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  83755. /**
  83756. * Calculates the minimum and maximum values of an array of position floats
  83757. * @param positions Positions array of a mesh
  83758. * @param vertexStart Starting vertex offset to calculate min and max values
  83759. * @param vertexCount Number of vertices to check for min and max values
  83760. * @returns min number array and max number array
  83761. */
  83762. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  83763. min: number[];
  83764. max: number[];
  83765. };
  83766. /**
  83767. * Converts a new right-handed Vector3
  83768. * @param vector vector3 array
  83769. * @returns right-handed Vector3
  83770. */
  83771. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  83772. /**
  83773. * Converts a Vector3 to right-handed
  83774. * @param vector Vector3 to convert to right-handed
  83775. */
  83776. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  83777. /**
  83778. * Converts a three element number array to right-handed
  83779. * @param vector number array to convert to right-handed
  83780. */
  83781. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  83782. /**
  83783. * Converts a new right-handed Vector3
  83784. * @param vector vector3 array
  83785. * @returns right-handed Vector3
  83786. */
  83787. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  83788. /**
  83789. * Converts a Vector3 to right-handed
  83790. * @param vector Vector3 to convert to right-handed
  83791. */
  83792. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  83793. /**
  83794. * Converts a three element number array to right-handed
  83795. * @param vector number array to convert to right-handed
  83796. */
  83797. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  83798. /**
  83799. * Converts a Vector4 to right-handed
  83800. * @param vector Vector4 to convert to right-handed
  83801. */
  83802. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  83803. /**
  83804. * Converts a Vector4 to right-handed
  83805. * @param vector Vector4 to convert to right-handed
  83806. */
  83807. static _GetRightHandedArray4FromRef(vector: number[]): void;
  83808. /**
  83809. * Converts a Quaternion to right-handed
  83810. * @param quaternion Source quaternion to convert to right-handed
  83811. */
  83812. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  83813. /**
  83814. * Converts a Quaternion to right-handed
  83815. * @param quaternion Source quaternion to convert to right-handed
  83816. */
  83817. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  83818. static _NormalizeTangentFromRef(tangent: Vector4): void;
  83819. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  83820. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  83821. }
  83822. }
  83823. declare module BABYLON.GLTF2.Exporter {
  83824. /**
  83825. * Converts Babylon Scene into glTF 2.0.
  83826. * @hidden
  83827. */
  83828. export class _Exporter {
  83829. /**
  83830. * Stores the glTF to export
  83831. */
  83832. _glTF: IGLTF;
  83833. /**
  83834. * Stores all generated buffer views, which represents views into the main glTF buffer data
  83835. */
  83836. _bufferViews: IBufferView[];
  83837. /**
  83838. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  83839. */
  83840. _accessors: IAccessor[];
  83841. /**
  83842. * Stores all the generated nodes, which contains transform and/or mesh information per node
  83843. */
  83844. _nodes: INode[];
  83845. /**
  83846. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  83847. */
  83848. private _scenes;
  83849. /**
  83850. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  83851. */
  83852. private _meshes;
  83853. /**
  83854. * Stores all the generated material information, which represents the appearance of each primitive
  83855. */
  83856. _materials: IMaterial[];
  83857. _materialMap: {
  83858. [materialID: number]: number;
  83859. };
  83860. /**
  83861. * Stores all the generated texture information, which is referenced by glTF materials
  83862. */
  83863. _textures: ITexture[];
  83864. /**
  83865. * Stores all the generated image information, which is referenced by glTF textures
  83866. */
  83867. _images: IImage[];
  83868. /**
  83869. * Stores all the texture samplers
  83870. */
  83871. _samplers: ISampler[];
  83872. /**
  83873. * Stores all the generated glTF skins
  83874. */
  83875. _skins: ISkin[];
  83876. /**
  83877. * Stores all the generated animation samplers, which is referenced by glTF animations
  83878. */
  83879. /**
  83880. * Stores the animations for glTF models
  83881. */
  83882. private _animations;
  83883. /**
  83884. * Stores the total amount of bytes stored in the glTF buffer
  83885. */
  83886. private _totalByteLength;
  83887. /**
  83888. * Stores a reference to the Babylon scene containing the source geometry and material information
  83889. */
  83890. _babylonScene: Scene;
  83891. /**
  83892. * Stores a map of the image data, where the key is the file name and the value
  83893. * is the image data
  83894. */
  83895. _imageData: {
  83896. [fileName: string]: {
  83897. data: Uint8Array;
  83898. mimeType: ImageMimeType;
  83899. };
  83900. };
  83901. protected _orderedImageData: Array<{
  83902. data: Uint8Array;
  83903. mimeType: ImageMimeType;
  83904. }>;
  83905. /**
  83906. * Stores a map of the unique id of a node to its index in the node array
  83907. */
  83908. _nodeMap: {
  83909. [key: number]: number;
  83910. };
  83911. /**
  83912. * Specifies if the source Babylon scene was left handed, and needed conversion.
  83913. */
  83914. _convertToRightHandedSystem: boolean;
  83915. /**
  83916. * Specifies if a Babylon node should be converted to right-handed on export
  83917. */
  83918. _convertToRightHandedSystemMap: {
  83919. [nodeId: number]: boolean;
  83920. };
  83921. _includeCoordinateSystemConversionNodes: boolean;
  83922. /**
  83923. * Baked animation sample rate
  83924. */
  83925. private _animationSampleRate;
  83926. private _options;
  83927. private _localEngine;
  83928. _glTFMaterialExporter: _GLTFMaterialExporter;
  83929. private _extensions;
  83930. private static _ExtensionNames;
  83931. private static _ExtensionFactories;
  83932. private _applyExtension;
  83933. private _applyExtensions;
  83934. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  83935. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  83936. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  83937. [key: number]: number;
  83938. }): Promise<Nullable<INode>>;
  83939. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  83940. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  83941. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  83942. private _forEachExtensions;
  83943. private _extensionsOnExporting;
  83944. /**
  83945. * Load glTF serializer extensions
  83946. */
  83947. private _loadExtensions;
  83948. /**
  83949. * Creates a glTF Exporter instance, which can accept optional exporter options
  83950. * @param babylonScene Babylon scene object
  83951. * @param options Options to modify the behavior of the exporter
  83952. */
  83953. constructor(babylonScene: Scene, options?: IExportOptions);
  83954. dispose(): void;
  83955. /**
  83956. * Registers a glTF exporter extension
  83957. * @param name Name of the extension to export
  83958. * @param factory The factory function that creates the exporter extension
  83959. */
  83960. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  83961. /**
  83962. * Un-registers an exporter extension
  83963. * @param name The name fo the exporter extension
  83964. * @returns A boolean indicating whether the extension has been un-registered
  83965. */
  83966. static UnregisterExtension(name: string): boolean;
  83967. /**
  83968. * Lazy load a local engine
  83969. */
  83970. _getLocalEngine(): Engine;
  83971. private reorderIndicesBasedOnPrimitiveMode;
  83972. /**
  83973. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  83974. * clock-wise during export to glTF
  83975. * @param submesh BabylonJS submesh
  83976. * @param primitiveMode Primitive mode of the mesh
  83977. * @param sideOrientation the winding order of the submesh
  83978. * @param vertexBufferKind The type of vertex attribute
  83979. * @param meshAttributeArray The vertex attribute data
  83980. * @param byteOffset The offset to the binary data
  83981. * @param binaryWriter The binary data for the glTF file
  83982. * @param convertToRightHandedSystem Converts the values to right-handed
  83983. */
  83984. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  83985. /**
  83986. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  83987. * clock-wise during export to glTF
  83988. * @param submesh BabylonJS submesh
  83989. * @param primitiveMode Primitive mode of the mesh
  83990. * @param sideOrientation the winding order of the submesh
  83991. * @param vertexBufferKind The type of vertex attribute
  83992. * @param meshAttributeArray The vertex attribute data
  83993. * @param byteOffset The offset to the binary data
  83994. * @param binaryWriter The binary data for the glTF file
  83995. * @param convertToRightHandedSystem Converts the values to right-handed
  83996. */
  83997. private reorderTriangleFillMode;
  83998. /**
  83999. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  84000. * clock-wise during export to glTF
  84001. * @param submesh BabylonJS submesh
  84002. * @param primitiveMode Primitive mode of the mesh
  84003. * @param sideOrientation the winding order of the submesh
  84004. * @param vertexBufferKind The type of vertex attribute
  84005. * @param meshAttributeArray The vertex attribute data
  84006. * @param byteOffset The offset to the binary data
  84007. * @param binaryWriter The binary data for the glTF file
  84008. * @param convertToRightHandedSystem Converts the values to right-handed
  84009. */
  84010. private reorderTriangleStripDrawMode;
  84011. /**
  84012. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  84013. * clock-wise during export to glTF
  84014. * @param submesh BabylonJS submesh
  84015. * @param primitiveMode Primitive mode of the mesh
  84016. * @param sideOrientation the winding order of the submesh
  84017. * @param vertexBufferKind The type of vertex attribute
  84018. * @param meshAttributeArray The vertex attribute data
  84019. * @param byteOffset The offset to the binary data
  84020. * @param binaryWriter The binary data for the glTF file
  84021. * @param convertToRightHandedSystem Converts the values to right-handed
  84022. */
  84023. private reorderTriangleFanMode;
  84024. /**
  84025. * Writes the vertex attribute data to binary
  84026. * @param vertices The vertices to write to the binary writer
  84027. * @param byteOffset The offset into the binary writer to overwrite binary data
  84028. * @param vertexAttributeKind The vertex attribute type
  84029. * @param meshAttributeArray The vertex attribute data
  84030. * @param binaryWriter The writer containing the binary data
  84031. * @param convertToRightHandedSystem Converts the values to right-handed
  84032. */
  84033. private writeVertexAttributeData;
  84034. /**
  84035. * Writes mesh attribute data to a data buffer
  84036. * Returns the bytelength of the data
  84037. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  84038. * @param meshAttributeArray Array containing the attribute data
  84039. * @param byteStride Specifies the space between data
  84040. * @param binaryWriter The buffer to write the binary data to
  84041. * @param convertToRightHandedSystem Converts the values to right-handed
  84042. */
  84043. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  84044. /**
  84045. * Writes mesh attribute data to a data buffer
  84046. * Returns the bytelength of the data
  84047. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  84048. * @param meshAttributeArray Array containing the attribute data
  84049. * @param byteStride Specifies the space between data
  84050. * @param binaryWriter The buffer to write the binary data to
  84051. * @param convertToRightHandedSystem Converts the values to right-handed
  84052. */
  84053. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  84054. /**
  84055. * Generates glTF json data
  84056. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  84057. * @param glTFPrefix Text to use when prefixing a glTF file
  84058. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  84059. * @returns json data as string
  84060. */
  84061. private generateJSON;
  84062. /**
  84063. * Generates data for .gltf and .bin files based on the glTF prefix string
  84064. * @param glTFPrefix Text to use when prefixing a glTF file
  84065. * @param dispose Dispose the exporter
  84066. * @returns GLTFData with glTF file data
  84067. */
  84068. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  84069. /**
  84070. * Creates a binary buffer for glTF
  84071. * @returns array buffer for binary data
  84072. */
  84073. private _generateBinaryAsync;
  84074. /**
  84075. * Pads the number to a multiple of 4
  84076. * @param num number to pad
  84077. * @returns padded number
  84078. */
  84079. private _getPadding;
  84080. /**
  84081. * @hidden
  84082. */
  84083. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  84084. /**
  84085. * Sets the TRS for each node
  84086. * @param node glTF Node for storing the transformation data
  84087. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  84088. * @param convertToRightHandedSystem Converts the values to right-handed
  84089. */
  84090. private setNodeTransformation;
  84091. private getVertexBufferFromMesh;
  84092. /**
  84093. * Creates a bufferview based on the vertices type for the Babylon mesh
  84094. * @param kind Indicates the type of vertices data
  84095. * @param componentType Indicates the numerical type used to store the data
  84096. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  84097. * @param binaryWriter The buffer to write the bufferview data to
  84098. * @param convertToRightHandedSystem Converts the values to right-handed
  84099. */
  84100. private createBufferViewKind;
  84101. /**
  84102. * Creates a bufferview based on the vertices type for the Babylon mesh
  84103. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  84104. * @param babylonMorphTarget the morph target to be exported
  84105. * @param binaryWriter The buffer to write the bufferview data to
  84106. * @param convertToRightHandedSystem Converts the values to right-handed
  84107. */
  84108. private setMorphTargetAttributes;
  84109. /**
  84110. * The primitive mode of the Babylon mesh
  84111. * @param babylonMesh The BabylonJS mesh
  84112. */
  84113. private getMeshPrimitiveMode;
  84114. /**
  84115. * Sets the primitive mode of the glTF mesh primitive
  84116. * @param meshPrimitive glTF mesh primitive
  84117. * @param primitiveMode The primitive mode
  84118. */
  84119. private setPrimitiveMode;
  84120. /**
  84121. * Sets the vertex attribute accessor based of the glTF mesh primitive
  84122. * @param meshPrimitive glTF mesh primitive
  84123. * @param attributeKind vertex attribute
  84124. * @returns boolean specifying if uv coordinates are present
  84125. */
  84126. private setAttributeKind;
  84127. /**
  84128. * Sets data for the primitive attributes of each submesh
  84129. * @param mesh glTF Mesh object to store the primitive attribute information
  84130. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  84131. * @param binaryWriter Buffer to write the attribute data to
  84132. * @param convertToRightHandedSystem Converts the values to right-handed
  84133. */
  84134. private setPrimitiveAttributesAsync;
  84135. /**
  84136. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  84137. * @param node The node to check
  84138. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  84139. */
  84140. private isBabylonCoordinateSystemConvertingNode;
  84141. /**
  84142. * Creates a glTF scene based on the array of meshes
  84143. * Returns the the total byte offset
  84144. * @param babylonScene Babylon scene to get the mesh data from
  84145. * @param binaryWriter Buffer to write binary data to
  84146. */
  84147. private createSceneAsync;
  84148. /**
  84149. * Creates a mapping of Node unique id to node index and handles animations
  84150. * @param babylonScene Babylon Scene
  84151. * @param nodes Babylon transform nodes
  84152. * @param binaryWriter Buffer to write binary data to
  84153. * @returns Node mapping of unique id to index
  84154. */
  84155. private createNodeMapAndAnimationsAsync;
  84156. /**
  84157. * Creates a glTF node from a Babylon mesh
  84158. * @param babylonMesh Source Babylon mesh
  84159. * @param binaryWriter Buffer for storing geometry data
  84160. * @param convertToRightHandedSystem Converts the values to right-handed
  84161. * @param nodeMap Node mapping of unique id to glTF node index
  84162. * @returns glTF node
  84163. */
  84164. private createNodeAsync;
  84165. /**
  84166. * Creates a glTF skin from a Babylon skeleton
  84167. * @param babylonScene Babylon Scene
  84168. * @param nodes Babylon transform nodes
  84169. * @param binaryWriter Buffer to write binary data to
  84170. * @returns Node mapping of unique id to index
  84171. */
  84172. private createSkinsAsync;
  84173. }
  84174. /**
  84175. * @hidden
  84176. *
  84177. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  84178. */
  84179. export class _BinaryWriter {
  84180. /**
  84181. * Array buffer which stores all binary data
  84182. */
  84183. private _arrayBuffer;
  84184. /**
  84185. * View of the array buffer
  84186. */
  84187. private _dataView;
  84188. /**
  84189. * byte offset of data in array buffer
  84190. */
  84191. private _byteOffset;
  84192. /**
  84193. * Initialize binary writer with an initial byte length
  84194. * @param byteLength Initial byte length of the array buffer
  84195. */
  84196. constructor(byteLength: number);
  84197. /**
  84198. * Resize the array buffer to the specified byte length
  84199. * @param byteLength
  84200. */
  84201. private resizeBuffer;
  84202. /**
  84203. * Get an array buffer with the length of the byte offset
  84204. * @returns ArrayBuffer resized to the byte offset
  84205. */
  84206. getArrayBuffer(): ArrayBuffer;
  84207. /**
  84208. * Get the byte offset of the array buffer
  84209. * @returns byte offset
  84210. */
  84211. getByteOffset(): number;
  84212. /**
  84213. * Stores an UInt8 in the array buffer
  84214. * @param entry
  84215. * @param byteOffset If defined, specifies where to set the value as an offset.
  84216. */
  84217. setUInt8(entry: number, byteOffset?: number): void;
  84218. /**
  84219. * Stores an UInt16 in the array buffer
  84220. * @param entry
  84221. * @param byteOffset If defined, specifies where to set the value as an offset.
  84222. */
  84223. setUInt16(entry: number, byteOffset?: number): void;
  84224. /**
  84225. * Gets an UInt32 in the array buffer
  84226. * @param entry
  84227. * @param byteOffset If defined, specifies where to set the value as an offset.
  84228. */
  84229. getUInt32(byteOffset: number): number;
  84230. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  84231. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  84232. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  84233. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  84234. /**
  84235. * Stores a Float32 in the array buffer
  84236. * @param entry
  84237. */
  84238. setFloat32(entry: number, byteOffset?: number): void;
  84239. /**
  84240. * Stores an UInt32 in the array buffer
  84241. * @param entry
  84242. * @param byteOffset If defined, specifies where to set the value as an offset.
  84243. */
  84244. setUInt32(entry: number, byteOffset?: number): void;
  84245. }
  84246. }
  84247. declare module BABYLON.GLTF2.Exporter {
  84248. /**
  84249. * @hidden
  84250. * Interface to store animation data.
  84251. */
  84252. export interface _IAnimationData {
  84253. /**
  84254. * Keyframe data.
  84255. */
  84256. inputs: number[];
  84257. /**
  84258. * Value data.
  84259. */
  84260. outputs: number[][];
  84261. /**
  84262. * Animation interpolation data.
  84263. */
  84264. samplerInterpolation: AnimationSamplerInterpolation;
  84265. /**
  84266. * Minimum keyframe value.
  84267. */
  84268. inputsMin: number;
  84269. /**
  84270. * Maximum keyframe value.
  84271. */
  84272. inputsMax: number;
  84273. }
  84274. /**
  84275. * @hidden
  84276. */
  84277. export interface _IAnimationInfo {
  84278. /**
  84279. * The target channel for the animation
  84280. */
  84281. animationChannelTargetPath: AnimationChannelTargetPath;
  84282. /**
  84283. * The glTF accessor type for the data.
  84284. */
  84285. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  84286. /**
  84287. * Specifies if quaternions should be used.
  84288. */
  84289. useQuaternion: boolean;
  84290. }
  84291. /**
  84292. * @hidden
  84293. * Utility class for generating glTF animation data from BabylonJS.
  84294. */
  84295. export class _GLTFAnimation {
  84296. /**
  84297. * @ignore
  84298. *
  84299. * Creates glTF channel animation from BabylonJS animation.
  84300. * @param babylonTransformNode - BabylonJS mesh.
  84301. * @param animation - animation.
  84302. * @param animationChannelTargetPath - The target animation channel.
  84303. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  84304. * @param useQuaternion - Specifies if quaternions are used.
  84305. * @returns nullable IAnimationData
  84306. */
  84307. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  84308. private static _DeduceAnimationInfo;
  84309. /**
  84310. * @ignore
  84311. * Create node animations from the transform node animations
  84312. * @param babylonNode
  84313. * @param runtimeGLTFAnimation
  84314. * @param idleGLTFAnimations
  84315. * @param nodeMap
  84316. * @param nodes
  84317. * @param binaryWriter
  84318. * @param bufferViews
  84319. * @param accessors
  84320. * @param convertToRightHandedSystem
  84321. * @param animationSampleRate
  84322. */
  84323. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  84324. [key: number]: number;
  84325. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  84326. /**
  84327. * @ignore
  84328. * Create individual morph animations from the mesh's morph target animation tracks
  84329. * @param babylonNode
  84330. * @param runtimeGLTFAnimation
  84331. * @param idleGLTFAnimations
  84332. * @param nodeMap
  84333. * @param nodes
  84334. * @param binaryWriter
  84335. * @param bufferViews
  84336. * @param accessors
  84337. * @param convertToRightHandedSystem
  84338. * @param animationSampleRate
  84339. */
  84340. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  84341. [key: number]: number;
  84342. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  84343. /**
  84344. * @ignore
  84345. * Create node and morph animations from the animation groups
  84346. * @param babylonScene
  84347. * @param glTFAnimations
  84348. * @param nodeMap
  84349. * @param nodes
  84350. * @param binaryWriter
  84351. * @param bufferViews
  84352. * @param accessors
  84353. * @param convertToRightHandedSystemMap
  84354. * @param animationSampleRate
  84355. */
  84356. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  84357. [key: number]: number;
  84358. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  84359. [nodeId: number]: boolean;
  84360. }, animationSampleRate: number): void;
  84361. private static AddAnimation;
  84362. /**
  84363. * Create a baked animation
  84364. * @param babylonTransformNode BabylonJS mesh
  84365. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  84366. * @param animationChannelTargetPath animation target channel
  84367. * @param minFrame minimum animation frame
  84368. * @param maxFrame maximum animation frame
  84369. * @param fps frames per second of the animation
  84370. * @param inputs input key frames of the animation
  84371. * @param outputs output key frame data of the animation
  84372. * @param convertToRightHandedSystem converts the values to right-handed
  84373. * @param useQuaternion specifies if quaternions should be used
  84374. */
  84375. private static _CreateBakedAnimation;
  84376. private static _ConvertFactorToVector3OrQuaternion;
  84377. private static _SetInterpolatedValue;
  84378. /**
  84379. * Creates linear animation from the animation key frames
  84380. * @param babylonTransformNode BabylonJS mesh
  84381. * @param animation BabylonJS animation
  84382. * @param animationChannelTargetPath The target animation channel
  84383. * @param frameDelta The difference between the last and first frame of the animation
  84384. * @param inputs Array to store the key frame times
  84385. * @param outputs Array to store the key frame data
  84386. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  84387. * @param useQuaternion Specifies if quaternions are used in the animation
  84388. */
  84389. private static _CreateLinearOrStepAnimation;
  84390. /**
  84391. * Creates cubic spline animation from the animation key frames
  84392. * @param babylonTransformNode BabylonJS mesh
  84393. * @param animation BabylonJS animation
  84394. * @param animationChannelTargetPath The target animation channel
  84395. * @param frameDelta The difference between the last and first frame of the animation
  84396. * @param inputs Array to store the key frame times
  84397. * @param outputs Array to store the key frame data
  84398. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  84399. * @param useQuaternion Specifies if quaternions are used in the animation
  84400. */
  84401. private static _CreateCubicSplineAnimation;
  84402. private static _GetBasePositionRotationOrScale;
  84403. /**
  84404. * Adds a key frame value
  84405. * @param keyFrame
  84406. * @param animation
  84407. * @param outputs
  84408. * @param animationChannelTargetPath
  84409. * @param basePositionRotationOrScale
  84410. * @param convertToRightHandedSystem
  84411. * @param useQuaternion
  84412. */
  84413. private static _AddKeyframeValue;
  84414. /**
  84415. * Determine the interpolation based on the key frames
  84416. * @param keyFrames
  84417. * @param animationChannelTargetPath
  84418. * @param useQuaternion
  84419. */
  84420. private static _DeduceInterpolation;
  84421. /**
  84422. * Adds an input tangent or output tangent to the output data
  84423. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  84424. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  84425. * @param outputs The animation data by keyframe
  84426. * @param animationChannelTargetPath The target animation channel
  84427. * @param interpolation The interpolation type
  84428. * @param keyFrame The key frame with the animation data
  84429. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  84430. * @param useQuaternion Specifies if quaternions are used
  84431. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  84432. */
  84433. private static AddSplineTangent;
  84434. /**
  84435. * Get the minimum and maximum key frames' frame values
  84436. * @param keyFrames animation key frames
  84437. * @returns the minimum and maximum key frame value
  84438. */
  84439. private static calculateMinMaxKeyFrames;
  84440. }
  84441. }
  84442. declare module BABYLON.GLTF2.Exporter {
  84443. /** @hidden */
  84444. export var textureTransformPixelShader: {
  84445. name: string;
  84446. shader: string;
  84447. };
  84448. }
  84449. declare module BABYLON.GLTF2.Exporter.Extensions {
  84450. /**
  84451. * @hidden
  84452. */
  84453. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  84454. private _recordedTextures;
  84455. /** Name of this extension */
  84456. readonly name: string;
  84457. /** Defines whether this extension is enabled */
  84458. enabled: boolean;
  84459. /** Defines whether this extension is required */
  84460. required: boolean;
  84461. /** Reference to the glTF exporter */
  84462. private _wasUsed;
  84463. constructor(exporter: _Exporter);
  84464. dispose(): void;
  84465. /** @hidden */
  84466. get wasUsed(): boolean;
  84467. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  84468. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  84469. /**
  84470. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  84471. * @param babylonTexture
  84472. * @param offset
  84473. * @param rotation
  84474. * @param scale
  84475. * @param scene
  84476. */
  84477. private _textureTransformTextureAsync;
  84478. }
  84479. }
  84480. declare module BABYLON.GLTF2.Exporter.Extensions {
  84481. /**
  84482. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  84483. */
  84484. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  84485. /** The name of this extension. */
  84486. readonly name: string;
  84487. /** Defines whether this extension is enabled. */
  84488. enabled: boolean;
  84489. /** Defines whether this extension is required */
  84490. required: boolean;
  84491. /** Reference to the glTF exporter */
  84492. private _exporter;
  84493. private _lights;
  84494. /** @hidden */
  84495. constructor(exporter: _Exporter);
  84496. /** @hidden */
  84497. dispose(): void;
  84498. /** @hidden */
  84499. get wasUsed(): boolean;
  84500. /** @hidden */
  84501. onExporting(): void;
  84502. /**
  84503. * Define this method to modify the default behavior when exporting a node
  84504. * @param context The context when exporting the node
  84505. * @param node glTF node
  84506. * @param babylonNode BabylonJS node
  84507. * @param nodeMap Node mapping of unique id to glTF node index
  84508. * @returns nullable INode promise
  84509. */
  84510. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  84511. [key: number]: number;
  84512. }): Promise<Nullable<INode>>;
  84513. }
  84514. }
  84515. declare module BABYLON.GLTF2.Exporter.Extensions {
  84516. /**
  84517. * @hidden
  84518. */
  84519. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  84520. /** Name of this extension */
  84521. readonly name: string;
  84522. /** Defines whether this extension is enabled */
  84523. enabled: boolean;
  84524. /** Defines whether this extension is required */
  84525. required: boolean;
  84526. /** Reference to the glTF exporter */
  84527. private _textureInfos;
  84528. private _exportedTextures;
  84529. private _wasUsed;
  84530. constructor(exporter: _Exporter);
  84531. dispose(): void;
  84532. /** @hidden */
  84533. get wasUsed(): boolean;
  84534. private _getTextureIndex;
  84535. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  84536. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  84537. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  84538. }
  84539. }
  84540. declare module BABYLON.GLTF2.Exporter.Extensions {
  84541. /**
  84542. * @hidden
  84543. */
  84544. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  84545. /** Name of this extension */
  84546. readonly name: string;
  84547. /** Defines whether this extension is enabled */
  84548. enabled: boolean;
  84549. /** Defines whether this extension is required */
  84550. required: boolean;
  84551. private _wasUsed;
  84552. constructor(exporter: _Exporter);
  84553. /** @hidden */
  84554. get wasUsed(): boolean;
  84555. dispose(): void;
  84556. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  84557. }
  84558. }
  84559. declare module BABYLON {
  84560. /**
  84561. * Class for generating STL data from a Babylon scene.
  84562. */
  84563. export class STLExport {
  84564. /**
  84565. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  84566. * @param meshes list defines the mesh to serialize
  84567. * @param download triggers the automatic download of the file.
  84568. * @param fileName changes the downloads fileName.
  84569. * @param binary changes the STL to a binary type.
  84570. * @param isLittleEndian toggle for binary type exporter.
  84571. * @returns the STL as UTF8 string
  84572. */
  84573. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  84574. }
  84575. }
  84576. declare module "babylonjs-gltf2interface" {
  84577. export = BABYLON.GLTF2;
  84578. }
  84579. /**
  84580. * Module for glTF 2.0 Interface
  84581. */
  84582. declare module BABYLON.GLTF2 {
  84583. /**
  84584. * The datatype of the components in the attribute
  84585. */
  84586. const enum AccessorComponentType {
  84587. /**
  84588. * Byte
  84589. */
  84590. BYTE = 5120,
  84591. /**
  84592. * Unsigned Byte
  84593. */
  84594. UNSIGNED_BYTE = 5121,
  84595. /**
  84596. * Short
  84597. */
  84598. SHORT = 5122,
  84599. /**
  84600. * Unsigned Short
  84601. */
  84602. UNSIGNED_SHORT = 5123,
  84603. /**
  84604. * Unsigned Int
  84605. */
  84606. UNSIGNED_INT = 5125,
  84607. /**
  84608. * Float
  84609. */
  84610. FLOAT = 5126,
  84611. }
  84612. /**
  84613. * Specifies if the attirbute is a scalar, vector, or matrix
  84614. */
  84615. const enum AccessorType {
  84616. /**
  84617. * Scalar
  84618. */
  84619. SCALAR = "SCALAR",
  84620. /**
  84621. * Vector2
  84622. */
  84623. VEC2 = "VEC2",
  84624. /**
  84625. * Vector3
  84626. */
  84627. VEC3 = "VEC3",
  84628. /**
  84629. * Vector4
  84630. */
  84631. VEC4 = "VEC4",
  84632. /**
  84633. * Matrix2x2
  84634. */
  84635. MAT2 = "MAT2",
  84636. /**
  84637. * Matrix3x3
  84638. */
  84639. MAT3 = "MAT3",
  84640. /**
  84641. * Matrix4x4
  84642. */
  84643. MAT4 = "MAT4",
  84644. }
  84645. /**
  84646. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  84647. */
  84648. const enum AnimationChannelTargetPath {
  84649. /**
  84650. * Translation
  84651. */
  84652. TRANSLATION = "translation",
  84653. /**
  84654. * Rotation
  84655. */
  84656. ROTATION = "rotation",
  84657. /**
  84658. * Scale
  84659. */
  84660. SCALE = "scale",
  84661. /**
  84662. * Weights
  84663. */
  84664. WEIGHTS = "weights",
  84665. }
  84666. /**
  84667. * Interpolation algorithm
  84668. */
  84669. const enum AnimationSamplerInterpolation {
  84670. /**
  84671. * The animated values are linearly interpolated between keyframes
  84672. */
  84673. LINEAR = "LINEAR",
  84674. /**
  84675. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  84676. */
  84677. STEP = "STEP",
  84678. /**
  84679. * The animation's interpolation is computed using a cubic spline with specified tangents
  84680. */
  84681. CUBICSPLINE = "CUBICSPLINE",
  84682. }
  84683. /**
  84684. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  84685. */
  84686. const enum CameraType {
  84687. /**
  84688. * A perspective camera containing properties to create a perspective projection matrix
  84689. */
  84690. PERSPECTIVE = "perspective",
  84691. /**
  84692. * An orthographic camera containing properties to create an orthographic projection matrix
  84693. */
  84694. ORTHOGRAPHIC = "orthographic",
  84695. }
  84696. /**
  84697. * The mime-type of the image
  84698. */
  84699. const enum ImageMimeType {
  84700. /**
  84701. * JPEG Mime-type
  84702. */
  84703. JPEG = "image/jpeg",
  84704. /**
  84705. * PNG Mime-type
  84706. */
  84707. PNG = "image/png",
  84708. }
  84709. /**
  84710. * The alpha rendering mode of the material
  84711. */
  84712. const enum MaterialAlphaMode {
  84713. /**
  84714. * The alpha value is ignored and the rendered output is fully opaque
  84715. */
  84716. OPAQUE = "OPAQUE",
  84717. /**
  84718. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  84719. */
  84720. MASK = "MASK",
  84721. /**
  84722. * 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)
  84723. */
  84724. BLEND = "BLEND",
  84725. }
  84726. /**
  84727. * The type of the primitives to render
  84728. */
  84729. const enum MeshPrimitiveMode {
  84730. /**
  84731. * Points
  84732. */
  84733. POINTS = 0,
  84734. /**
  84735. * Lines
  84736. */
  84737. LINES = 1,
  84738. /**
  84739. * Line Loop
  84740. */
  84741. LINE_LOOP = 2,
  84742. /**
  84743. * Line Strip
  84744. */
  84745. LINE_STRIP = 3,
  84746. /**
  84747. * Triangles
  84748. */
  84749. TRIANGLES = 4,
  84750. /**
  84751. * Triangle Strip
  84752. */
  84753. TRIANGLE_STRIP = 5,
  84754. /**
  84755. * Triangle Fan
  84756. */
  84757. TRIANGLE_FAN = 6,
  84758. }
  84759. /**
  84760. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  84761. */
  84762. const enum TextureMagFilter {
  84763. /**
  84764. * Nearest
  84765. */
  84766. NEAREST = 9728,
  84767. /**
  84768. * Linear
  84769. */
  84770. LINEAR = 9729,
  84771. }
  84772. /**
  84773. * Minification filter. All valid values correspond to WebGL enums
  84774. */
  84775. const enum TextureMinFilter {
  84776. /**
  84777. * Nearest
  84778. */
  84779. NEAREST = 9728,
  84780. /**
  84781. * Linear
  84782. */
  84783. LINEAR = 9729,
  84784. /**
  84785. * Nearest Mip-Map Nearest
  84786. */
  84787. NEAREST_MIPMAP_NEAREST = 9984,
  84788. /**
  84789. * Linear Mipmap Nearest
  84790. */
  84791. LINEAR_MIPMAP_NEAREST = 9985,
  84792. /**
  84793. * Nearest Mipmap Linear
  84794. */
  84795. NEAREST_MIPMAP_LINEAR = 9986,
  84796. /**
  84797. * Linear Mipmap Linear
  84798. */
  84799. LINEAR_MIPMAP_LINEAR = 9987,
  84800. }
  84801. /**
  84802. * S (U) wrapping mode. All valid values correspond to WebGL enums
  84803. */
  84804. const enum TextureWrapMode {
  84805. /**
  84806. * Clamp to Edge
  84807. */
  84808. CLAMP_TO_EDGE = 33071,
  84809. /**
  84810. * Mirrored Repeat
  84811. */
  84812. MIRRORED_REPEAT = 33648,
  84813. /**
  84814. * Repeat
  84815. */
  84816. REPEAT = 10497,
  84817. }
  84818. /**
  84819. * glTF Property
  84820. */
  84821. interface IProperty {
  84822. /**
  84823. * Dictionary object with extension-specific objects
  84824. */
  84825. extensions?: {
  84826. [key: string]: any;
  84827. };
  84828. /**
  84829. * Application-Specific data
  84830. */
  84831. extras?: any;
  84832. }
  84833. /**
  84834. * glTF Child of Root Property
  84835. */
  84836. interface IChildRootProperty extends IProperty {
  84837. /**
  84838. * The user-defined name of this object
  84839. */
  84840. name?: string;
  84841. }
  84842. /**
  84843. * Indices of those attributes that deviate from their initialization value
  84844. */
  84845. interface IAccessorSparseIndices extends IProperty {
  84846. /**
  84847. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  84848. */
  84849. bufferView: number;
  84850. /**
  84851. * The offset relative to the start of the bufferView in bytes. Must be aligned
  84852. */
  84853. byteOffset?: number;
  84854. /**
  84855. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  84856. */
  84857. componentType: AccessorComponentType;
  84858. }
  84859. /**
  84860. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  84861. */
  84862. interface IAccessorSparseValues extends IProperty {
  84863. /**
  84864. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  84865. */
  84866. bufferView: number;
  84867. /**
  84868. * The offset relative to the start of the bufferView in bytes. Must be aligned
  84869. */
  84870. byteOffset?: number;
  84871. }
  84872. /**
  84873. * Sparse storage of attributes that deviate from their initialization value
  84874. */
  84875. interface IAccessorSparse extends IProperty {
  84876. /**
  84877. * The number of attributes encoded in this sparse accessor
  84878. */
  84879. count: number;
  84880. /**
  84881. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  84882. */
  84883. indices: IAccessorSparseIndices;
  84884. /**
  84885. * 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
  84886. */
  84887. values: IAccessorSparseValues;
  84888. }
  84889. /**
  84890. * 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
  84891. */
  84892. interface IAccessor extends IChildRootProperty {
  84893. /**
  84894. * The index of the bufferview
  84895. */
  84896. bufferView?: number;
  84897. /**
  84898. * The offset relative to the start of the bufferView in bytes
  84899. */
  84900. byteOffset?: number;
  84901. /**
  84902. * The datatype of components in the attribute
  84903. */
  84904. componentType: AccessorComponentType;
  84905. /**
  84906. * Specifies whether integer data values should be normalized
  84907. */
  84908. normalized?: boolean;
  84909. /**
  84910. * The number of attributes referenced by this accessor
  84911. */
  84912. count: number;
  84913. /**
  84914. * Specifies if the attribute is a scalar, vector, or matrix
  84915. */
  84916. type: AccessorType;
  84917. /**
  84918. * Maximum value of each component in this attribute
  84919. */
  84920. max?: number[];
  84921. /**
  84922. * Minimum value of each component in this attribute
  84923. */
  84924. min?: number[];
  84925. /**
  84926. * Sparse storage of attributes that deviate from their initialization value
  84927. */
  84928. sparse?: IAccessorSparse;
  84929. }
  84930. /**
  84931. * Targets an animation's sampler at a node's property
  84932. */
  84933. interface IAnimationChannel extends IProperty {
  84934. /**
  84935. * The index of a sampler in this animation used to compute the value for the target
  84936. */
  84937. sampler: number;
  84938. /**
  84939. * The index of the node and TRS property to target
  84940. */
  84941. target: IAnimationChannelTarget;
  84942. }
  84943. /**
  84944. * The index of the node and TRS property that an animation channel targets
  84945. */
  84946. interface IAnimationChannelTarget extends IProperty {
  84947. /**
  84948. * The index of the node to target
  84949. */
  84950. node: number;
  84951. /**
  84952. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  84953. */
  84954. path: AnimationChannelTargetPath;
  84955. }
  84956. /**
  84957. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  84958. */
  84959. interface IAnimationSampler extends IProperty {
  84960. /**
  84961. * The index of an accessor containing keyframe input values, e.g., time
  84962. */
  84963. input: number;
  84964. /**
  84965. * Interpolation algorithm
  84966. */
  84967. interpolation?: AnimationSamplerInterpolation;
  84968. /**
  84969. * The index of an accessor, containing keyframe output values
  84970. */
  84971. output: number;
  84972. }
  84973. /**
  84974. * A keyframe animation
  84975. */
  84976. interface IAnimation extends IChildRootProperty {
  84977. /**
  84978. * An array of channels, each of which targets an animation's sampler at a node's property
  84979. */
  84980. channels: IAnimationChannel[];
  84981. /**
  84982. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  84983. */
  84984. samplers: IAnimationSampler[];
  84985. }
  84986. /**
  84987. * Metadata about the glTF asset
  84988. */
  84989. interface IAsset extends IChildRootProperty {
  84990. /**
  84991. * A copyright message suitable for display to credit the content creator
  84992. */
  84993. copyright?: string;
  84994. /**
  84995. * Tool that generated this glTF model. Useful for debugging
  84996. */
  84997. generator?: string;
  84998. /**
  84999. * The glTF version that this asset targets
  85000. */
  85001. version: string;
  85002. /**
  85003. * The minimum glTF version that this asset targets
  85004. */
  85005. minVersion?: string;
  85006. }
  85007. /**
  85008. * A buffer points to binary geometry, animation, or skins
  85009. */
  85010. interface IBuffer extends IChildRootProperty {
  85011. /**
  85012. * 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
  85013. */
  85014. uri?: string;
  85015. /**
  85016. * The length of the buffer in bytes
  85017. */
  85018. byteLength: number;
  85019. }
  85020. /**
  85021. * A view into a buffer generally representing a subset of the buffer
  85022. */
  85023. interface IBufferView extends IChildRootProperty {
  85024. /**
  85025. * The index of the buffer
  85026. */
  85027. buffer: number;
  85028. /**
  85029. * The offset into the buffer in bytes
  85030. */
  85031. byteOffset?: number;
  85032. /**
  85033. * The lenth of the bufferView in bytes
  85034. */
  85035. byteLength: number;
  85036. /**
  85037. * The stride, in bytes
  85038. */
  85039. byteStride?: number;
  85040. }
  85041. /**
  85042. * An orthographic camera containing properties to create an orthographic projection matrix
  85043. */
  85044. interface ICameraOrthographic extends IProperty {
  85045. /**
  85046. * The floating-point horizontal magnification of the view. Must not be zero
  85047. */
  85048. xmag: number;
  85049. /**
  85050. * The floating-point vertical magnification of the view. Must not be zero
  85051. */
  85052. ymag: number;
  85053. /**
  85054. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  85055. */
  85056. zfar: number;
  85057. /**
  85058. * The floating-point distance to the near clipping plane
  85059. */
  85060. znear: number;
  85061. }
  85062. /**
  85063. * A perspective camera containing properties to create a perspective projection matrix
  85064. */
  85065. interface ICameraPerspective extends IProperty {
  85066. /**
  85067. * The floating-point aspect ratio of the field of view
  85068. */
  85069. aspectRatio?: number;
  85070. /**
  85071. * The floating-point vertical field of view in radians
  85072. */
  85073. yfov: number;
  85074. /**
  85075. * The floating-point distance to the far clipping plane
  85076. */
  85077. zfar?: number;
  85078. /**
  85079. * The floating-point distance to the near clipping plane
  85080. */
  85081. znear: number;
  85082. }
  85083. /**
  85084. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  85085. */
  85086. interface ICamera extends IChildRootProperty {
  85087. /**
  85088. * An orthographic camera containing properties to create an orthographic projection matrix
  85089. */
  85090. orthographic?: ICameraOrthographic;
  85091. /**
  85092. * A perspective camera containing properties to create a perspective projection matrix
  85093. */
  85094. perspective?: ICameraPerspective;
  85095. /**
  85096. * Specifies if the camera uses a perspective or orthographic projection
  85097. */
  85098. type: CameraType;
  85099. }
  85100. /**
  85101. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  85102. */
  85103. interface IImage extends IChildRootProperty {
  85104. /**
  85105. * 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
  85106. */
  85107. uri?: string;
  85108. /**
  85109. * The image's MIME type
  85110. */
  85111. mimeType?: ImageMimeType;
  85112. /**
  85113. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  85114. */
  85115. bufferView?: number;
  85116. }
  85117. /**
  85118. * Material Normal Texture Info
  85119. */
  85120. interface IMaterialNormalTextureInfo extends ITextureInfo {
  85121. /**
  85122. * The scalar multiplier applied to each normal vector of the normal texture
  85123. */
  85124. scale?: number;
  85125. }
  85126. /**
  85127. * Material Occlusion Texture Info
  85128. */
  85129. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  85130. /**
  85131. * A scalar multiplier controlling the amount of occlusion applied
  85132. */
  85133. strength?: number;
  85134. }
  85135. /**
  85136. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  85137. */
  85138. interface IMaterialPbrMetallicRoughness {
  85139. /**
  85140. * The material's base color factor
  85141. */
  85142. baseColorFactor?: number[];
  85143. /**
  85144. * The base color texture
  85145. */
  85146. baseColorTexture?: ITextureInfo;
  85147. /**
  85148. * The metalness of the material
  85149. */
  85150. metallicFactor?: number;
  85151. /**
  85152. * The roughness of the material
  85153. */
  85154. roughnessFactor?: number;
  85155. /**
  85156. * The metallic-roughness texture
  85157. */
  85158. metallicRoughnessTexture?: ITextureInfo;
  85159. }
  85160. /**
  85161. * The material appearance of a primitive
  85162. */
  85163. interface IMaterial extends IChildRootProperty {
  85164. /**
  85165. * 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
  85166. */
  85167. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  85168. /**
  85169. * The normal map texture
  85170. */
  85171. normalTexture?: IMaterialNormalTextureInfo;
  85172. /**
  85173. * The occlusion map texture
  85174. */
  85175. occlusionTexture?: IMaterialOcclusionTextureInfo;
  85176. /**
  85177. * The emissive map texture
  85178. */
  85179. emissiveTexture?: ITextureInfo;
  85180. /**
  85181. * 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
  85182. */
  85183. emissiveFactor?: number[];
  85184. /**
  85185. * The alpha rendering mode of the material
  85186. */
  85187. alphaMode?: MaterialAlphaMode;
  85188. /**
  85189. * The alpha cutoff value of the material
  85190. */
  85191. alphaCutoff?: number;
  85192. /**
  85193. * Specifies whether the material is double sided
  85194. */
  85195. doubleSided?: boolean;
  85196. }
  85197. /**
  85198. * Geometry to be rendered with the given material
  85199. */
  85200. interface IMeshPrimitive extends IProperty {
  85201. /**
  85202. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  85203. */
  85204. attributes: {
  85205. [name: string]: number;
  85206. };
  85207. /**
  85208. * The index of the accessor that contains the indices
  85209. */
  85210. indices?: number;
  85211. /**
  85212. * The index of the material to apply to this primitive when rendering
  85213. */
  85214. material?: number;
  85215. /**
  85216. * The type of primitives to render. All valid values correspond to WebGL enums
  85217. */
  85218. mode?: MeshPrimitiveMode;
  85219. /**
  85220. * 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
  85221. */
  85222. targets?: {
  85223. [name: string]: number;
  85224. }[];
  85225. }
  85226. /**
  85227. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  85228. */
  85229. interface IMesh extends IChildRootProperty {
  85230. /**
  85231. * An array of primitives, each defining geometry to be rendered with a material
  85232. */
  85233. primitives: IMeshPrimitive[];
  85234. /**
  85235. * Array of weights to be applied to the Morph Targets
  85236. */
  85237. weights?: number[];
  85238. }
  85239. /**
  85240. * A node in the node hierarchy
  85241. */
  85242. interface INode extends IChildRootProperty {
  85243. /**
  85244. * The index of the camera referenced by this node
  85245. */
  85246. camera?: number;
  85247. /**
  85248. * The indices of this node's children
  85249. */
  85250. children?: number[];
  85251. /**
  85252. * The index of the skin referenced by this node
  85253. */
  85254. skin?: number;
  85255. /**
  85256. * A floating-point 4x4 transformation matrix stored in column-major order
  85257. */
  85258. matrix?: number[];
  85259. /**
  85260. * The index of the mesh in this node
  85261. */
  85262. mesh?: number;
  85263. /**
  85264. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  85265. */
  85266. rotation?: number[];
  85267. /**
  85268. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  85269. */
  85270. scale?: number[];
  85271. /**
  85272. * The node's translation along the x, y, and z axes
  85273. */
  85274. translation?: number[];
  85275. /**
  85276. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  85277. */
  85278. weights?: number[];
  85279. }
  85280. /**
  85281. * Texture sampler properties for filtering and wrapping modes
  85282. */
  85283. interface ISampler extends IChildRootProperty {
  85284. /**
  85285. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  85286. */
  85287. magFilter?: TextureMagFilter;
  85288. /**
  85289. * Minification filter. All valid values correspond to WebGL enums
  85290. */
  85291. minFilter?: TextureMinFilter;
  85292. /**
  85293. * S (U) wrapping mode. All valid values correspond to WebGL enums
  85294. */
  85295. wrapS?: TextureWrapMode;
  85296. /**
  85297. * T (V) wrapping mode. All valid values correspond to WebGL enums
  85298. */
  85299. wrapT?: TextureWrapMode;
  85300. }
  85301. /**
  85302. * The root nodes of a scene
  85303. */
  85304. interface IScene extends IChildRootProperty {
  85305. /**
  85306. * The indices of each root node
  85307. */
  85308. nodes: number[];
  85309. }
  85310. /**
  85311. * Joints and matrices defining a skin
  85312. */
  85313. interface ISkin extends IChildRootProperty {
  85314. /**
  85315. * 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
  85316. */
  85317. inverseBindMatrices?: number;
  85318. /**
  85319. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  85320. */
  85321. skeleton?: number;
  85322. /**
  85323. * 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)
  85324. */
  85325. joints: number[];
  85326. }
  85327. /**
  85328. * A texture and its sampler
  85329. */
  85330. interface ITexture extends IChildRootProperty {
  85331. /**
  85332. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  85333. */
  85334. sampler?: number;
  85335. /**
  85336. * The index of the image used by this texture
  85337. */
  85338. source: number;
  85339. }
  85340. /**
  85341. * Reference to a texture
  85342. */
  85343. interface ITextureInfo extends IProperty {
  85344. /**
  85345. * The index of the texture
  85346. */
  85347. index: number;
  85348. /**
  85349. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  85350. */
  85351. texCoord?: number;
  85352. }
  85353. /**
  85354. * The root object for a glTF asset
  85355. */
  85356. interface IGLTF extends IProperty {
  85357. /**
  85358. * An array of accessors. An accessor is a typed view into a bufferView
  85359. */
  85360. accessors?: IAccessor[];
  85361. /**
  85362. * An array of keyframe animations
  85363. */
  85364. animations?: IAnimation[];
  85365. /**
  85366. * Metadata about the glTF asset
  85367. */
  85368. asset: IAsset;
  85369. /**
  85370. * An array of buffers. A buffer points to binary geometry, animation, or skins
  85371. */
  85372. buffers?: IBuffer[];
  85373. /**
  85374. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  85375. */
  85376. bufferViews?: IBufferView[];
  85377. /**
  85378. * An array of cameras
  85379. */
  85380. cameras?: ICamera[];
  85381. /**
  85382. * Names of glTF extensions used somewhere in this asset
  85383. */
  85384. extensionsUsed?: string[];
  85385. /**
  85386. * Names of glTF extensions required to properly load this asset
  85387. */
  85388. extensionsRequired?: string[];
  85389. /**
  85390. * An array of images. An image defines data used to create a texture
  85391. */
  85392. images?: IImage[];
  85393. /**
  85394. * An array of materials. A material defines the appearance of a primitive
  85395. */
  85396. materials?: IMaterial[];
  85397. /**
  85398. * An array of meshes. A mesh is a set of primitives to be rendered
  85399. */
  85400. meshes?: IMesh[];
  85401. /**
  85402. * An array of nodes
  85403. */
  85404. nodes?: INode[];
  85405. /**
  85406. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  85407. */
  85408. samplers?: ISampler[];
  85409. /**
  85410. * The index of the default scene
  85411. */
  85412. scene?: number;
  85413. /**
  85414. * An array of scenes
  85415. */
  85416. scenes?: IScene[];
  85417. /**
  85418. * An array of skins. A skin is defined by joints and matrices
  85419. */
  85420. skins?: ISkin[];
  85421. /**
  85422. * An array of textures
  85423. */
  85424. textures?: ITexture[];
  85425. }
  85426. /**
  85427. * The glTF validation results
  85428. * @ignore
  85429. */
  85430. interface IGLTFValidationResults {
  85431. info: {
  85432. generator: string;
  85433. hasAnimations: boolean;
  85434. hasDefaultScene: boolean;
  85435. hasMaterials: boolean;
  85436. hasMorphTargets: boolean;
  85437. hasSkins: boolean;
  85438. hasTextures: boolean;
  85439. maxAttributesUsed: number;
  85440. primitivesCount: number
  85441. };
  85442. issues: {
  85443. messages: Array<string>;
  85444. numErrors: number;
  85445. numHints: number;
  85446. numInfos: number;
  85447. numWarnings: number;
  85448. truncated: boolean
  85449. };
  85450. mimeType: string;
  85451. uri: string;
  85452. validatedAt: string;
  85453. validatorVersion: string;
  85454. }
  85455. /**
  85456. * The glTF validation options
  85457. */
  85458. interface IGLTFValidationOptions {
  85459. /** Uri to use */
  85460. uri?: string;
  85461. /** Function used to load external resources */
  85462. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  85463. /** Boolean indicating that we need to validate accessor data */
  85464. validateAccessorData?: boolean;
  85465. /** max number of issues allowed */
  85466. maxIssues?: number;
  85467. /** Ignored issues */
  85468. ignoredIssues?: Array<string>;
  85469. /** Value to override severy settings */
  85470. severityOverrides?: Object;
  85471. }
  85472. /**
  85473. * The glTF validator object
  85474. * @ignore
  85475. */
  85476. interface IGLTFValidator {
  85477. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  85478. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  85479. }
  85480. /**
  85481. * Interfaces from the EXT_lights_image_based extension
  85482. */
  85483. /** @hidden */
  85484. interface IEXTLightsImageBased_LightReferenceImageBased {
  85485. light: number;
  85486. }
  85487. /** @hidden */
  85488. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  85489. intensity: number;
  85490. rotation: number[];
  85491. specularImageSize: number;
  85492. specularImages: number[][];
  85493. irradianceCoefficients: number[][];
  85494. }
  85495. /** @hidden */
  85496. interface IEXTLightsImageBased {
  85497. lights: IEXTLightsImageBased_LightImageBased[];
  85498. }
  85499. /**
  85500. * Interfaces from the EXT_mesh_gpu_instancing extension
  85501. * !!! Experimental Extension Subject to Changes !!!
  85502. */
  85503. /** @hidden */
  85504. interface IEXTMeshGpuInstancing {
  85505. mesh?: number;
  85506. attributes: { [name: string]: number };
  85507. }
  85508. /**
  85509. * Interfaces from the KHR_draco_mesh_compression extension
  85510. */
  85511. /** @hidden */
  85512. interface IKHRDracoMeshCompression {
  85513. bufferView: number;
  85514. attributes: { [name: string]: number };
  85515. }
  85516. /**
  85517. * Interfaces from the KHR_lights_punctual extension
  85518. */
  85519. /** @hidden */
  85520. const enum IKHRLightsPunctual_LightType {
  85521. DIRECTIONAL = "directional",
  85522. POINT = "point",
  85523. SPOT = "spot"
  85524. }
  85525. /** @hidden */
  85526. interface IKHRLightsPunctual_LightReference {
  85527. light: number;
  85528. }
  85529. /** @hidden */
  85530. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  85531. type: IKHRLightsPunctual_LightType;
  85532. color?: number[];
  85533. intensity?: number;
  85534. range?: number;
  85535. spot?: {
  85536. innerConeAngle?: number;
  85537. outerConeAngle?: number;
  85538. };
  85539. }
  85540. /** @hidden */
  85541. interface IKHRLightsPunctual {
  85542. lights: IKHRLightsPunctual_Light[];
  85543. }
  85544. /**
  85545. * Interfaces from the KHR_materials_clearcoat extension
  85546. * !!! Experimental Extension Subject to Changes !!!
  85547. */
  85548. /** @hidden */
  85549. interface IKHRMaterialsClearcoat {
  85550. clearcoatFactor: number;
  85551. clearcoatTexture: ITextureInfo;
  85552. clearcoatRoughnessFactor: number;
  85553. clearcoatRoughnessTexture: ITextureInfo;
  85554. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  85555. }
  85556. /**
  85557. * Interfaces from the KHR_materials_ior extension
  85558. * !!! Experimental Extension Subject to Changes !!!
  85559. */
  85560. /** @hidden */
  85561. interface IKHRMaterialsIor {
  85562. ior: number;
  85563. }
  85564. /**
  85565. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  85566. */
  85567. /** @hidden */
  85568. interface IKHRMaterialsPbrSpecularGlossiness {
  85569. diffuseFactor: number[];
  85570. diffuseTexture: ITextureInfo;
  85571. specularFactor: number[];
  85572. glossinessFactor: number;
  85573. specularGlossinessTexture: ITextureInfo;
  85574. }
  85575. /**
  85576. * Interfaces from the KHR_materials_sheen extension
  85577. * !!! Experimental Extension Subject to Changes !!!
  85578. */
  85579. /** @hidden */
  85580. interface IKHRMaterialsSheen {
  85581. sheenColorFactor?: number[];
  85582. sheenTexture?: ITextureInfo;
  85583. sheenRoughnessFactor?: number;
  85584. }
  85585. /**
  85586. * Interfaces from the KHR_materials_specular extension
  85587. * !!! Experimental Extension Subject to Changes !!!
  85588. */
  85589. /** @hidden */
  85590. interface IKHRMaterialsSpecular {
  85591. specularFactor: number;
  85592. specularColorFactor: number[];
  85593. specularTexture: ITextureInfo;
  85594. }
  85595. /**
  85596. * Interfaces from the KHR_materials_transmission extension
  85597. * !!! Experimental Extension Subject to Changes !!!
  85598. */
  85599. /** @hidden */
  85600. interface IKHRMaterialsTransmission {
  85601. transmissionFactor?: number;
  85602. transmissionTexture?: ITextureInfo;
  85603. }
  85604. /**
  85605. * Interfaces from the KHR_materials_variants extension
  85606. * !!! Experimental Extension Subject to Changes !!!
  85607. */
  85608. /** @hidden */
  85609. interface IKHRMaterialVariants_Mapping extends IProperty {
  85610. mappings: Array<{
  85611. variants: number[];
  85612. material: number;
  85613. }>;
  85614. }
  85615. /** @hidden */
  85616. interface IKHRMaterialVariants_Variant extends IProperty {
  85617. name: string;
  85618. }
  85619. /** @hidden */
  85620. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  85621. variants: Array<IKHRMaterialVariants_Variant>;
  85622. }
  85623. /**
  85624. * Interfaces from the KHR_texture_basisu extension
  85625. * !!! Experimental Extension Subject to Changes !!!
  85626. */
  85627. /** @hidden */
  85628. interface IKHRTextureBasisU {
  85629. source: number;
  85630. }
  85631. /**
  85632. * Interfaces from the EXT_texture_webp extension
  85633. */
  85634. /** @hidden */
  85635. interface IEXTTextureWebP {
  85636. source: number;
  85637. }
  85638. /**
  85639. * Interfaces from the KHR_texture_transform extension
  85640. */
  85641. /** @hidden */
  85642. interface IKHRTextureTransform {
  85643. offset?: number[];
  85644. rotation?: number;
  85645. scale?: number[];
  85646. texCoord?: number;
  85647. }
  85648. /**
  85649. * Interfaces from the KHR_xmp extension
  85650. * !!! Experimental Extension Subject to Changes !!!
  85651. */
  85652. /** @hidden */
  85653. interface IKHRXmp_Data {
  85654. [key: string]: unknown;
  85655. }
  85656. /** @hidden */
  85657. interface IKHRXmp_Gltf {
  85658. packets: IKHRXmp_Data[];
  85659. }
  85660. /** @hidden */
  85661. interface IKHRXmp_Node {
  85662. packet: number;
  85663. }
  85664. /**
  85665. * Interfaces from the MSFT_audio_emitter extension
  85666. */
  85667. /** @hidden */
  85668. interface IMSFTAudioEmitter_ClipReference {
  85669. clip: number;
  85670. weight?: number;
  85671. }
  85672. /** @hidden */
  85673. interface IMSFTAudioEmitter_EmittersReference {
  85674. emitters: number[];
  85675. }
  85676. /** @hidden */
  85677. const enum IMSFTAudioEmitter_DistanceModel {
  85678. linear = "linear",
  85679. inverse = "inverse",
  85680. exponential = "exponential",
  85681. }
  85682. /** @hidden */
  85683. interface IMSFTAudioEmitter_Emitter {
  85684. name?: string;
  85685. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  85686. refDistance?: number;
  85687. maxDistance?: number;
  85688. rolloffFactor?: number;
  85689. innerAngle?: number;
  85690. outerAngle?: number;
  85691. loop?: boolean;
  85692. volume?: number;
  85693. clips: IMSFTAudioEmitter_ClipReference[];
  85694. }
  85695. /** @hidden */
  85696. const enum IMSFTAudioEmitter_AudioMimeType {
  85697. WAV = "audio/wav",
  85698. }
  85699. /** @hidden */
  85700. interface IMSFTAudioEmitter_Clip extends IProperty {
  85701. uri?: string;
  85702. bufferView?: number;
  85703. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  85704. }
  85705. /** @hidden */
  85706. const enum IMSFTAudioEmitter_AnimationEventAction {
  85707. play = "play",
  85708. pause = "pause",
  85709. stop = "stop",
  85710. }
  85711. /** @hidden */
  85712. interface IMSFTAudioEmitter_AnimationEvent {
  85713. action: IMSFTAudioEmitter_AnimationEventAction;
  85714. emitter: number;
  85715. time: number;
  85716. startOffset?: number;
  85717. }
  85718. /**
  85719. * Interfaces from the MSFT_lod extension
  85720. */
  85721. /** @hidden */
  85722. interface IMSFTLOD {
  85723. ids: number[];
  85724. }
  85725. }
  85726. declare module BABYLON {
  85727. /** @hidden */
  85728. export var cellPixelShader: {
  85729. name: string;
  85730. shader: string;
  85731. };
  85732. }
  85733. declare module BABYLON {
  85734. /** @hidden */
  85735. export var cellVertexShader: {
  85736. name: string;
  85737. shader: string;
  85738. };
  85739. }
  85740. declare module BABYLON {
  85741. export class CellMaterial extends BABYLON.PushMaterial {
  85742. private _diffuseTexture;
  85743. diffuseTexture: BABYLON.BaseTexture;
  85744. diffuseColor: BABYLON.Color3;
  85745. _computeHighLevel: boolean;
  85746. computeHighLevel: boolean;
  85747. private _disableLighting;
  85748. disableLighting: boolean;
  85749. private _maxSimultaneousLights;
  85750. maxSimultaneousLights: number;
  85751. constructor(name: string, scene: BABYLON.Scene);
  85752. needAlphaBlending(): boolean;
  85753. needAlphaTesting(): boolean;
  85754. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85755. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85756. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85757. getAnimatables(): BABYLON.IAnimatable[];
  85758. getActiveTextures(): BABYLON.BaseTexture[];
  85759. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85760. dispose(forceDisposeEffect?: boolean): void;
  85761. getClassName(): string;
  85762. clone(name: string): CellMaterial;
  85763. serialize(): any;
  85764. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  85765. }
  85766. }
  85767. declare module BABYLON {
  85768. export class CustomShaderStructure {
  85769. FragmentStore: string;
  85770. VertexStore: string;
  85771. constructor();
  85772. }
  85773. export class ShaderSpecialParts {
  85774. constructor();
  85775. Fragment_Begin: string;
  85776. Fragment_Definitions: string;
  85777. Fragment_MainBegin: string;
  85778. Fragment_Custom_Diffuse: string;
  85779. Fragment_Before_Lights: string;
  85780. Fragment_Before_Fog: string;
  85781. Fragment_Custom_Alpha: string;
  85782. Fragment_Before_FragColor: string;
  85783. Vertex_Begin: string;
  85784. Vertex_Definitions: string;
  85785. Vertex_MainBegin: string;
  85786. Vertex_Before_PositionUpdated: string;
  85787. Vertex_Before_NormalUpdated: string;
  85788. Vertex_After_WorldPosComputed: string;
  85789. Vertex_MainEnd: string;
  85790. }
  85791. export class CustomMaterial extends BABYLON.StandardMaterial {
  85792. static ShaderIndexer: number;
  85793. CustomParts: ShaderSpecialParts;
  85794. _isCreatedShader: boolean;
  85795. _createdShaderName: string;
  85796. _customUniform: string[];
  85797. _newUniforms: string[];
  85798. _newUniformInstances: {
  85799. [name: string]: any;
  85800. };
  85801. _newSamplerInstances: {
  85802. [name: string]: BABYLON.Texture;
  85803. };
  85804. _customAttributes: string[];
  85805. FragmentShader: string;
  85806. VertexShader: string;
  85807. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  85808. ReviewUniform(name: string, arr: string[]): string[];
  85809. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  85810. constructor(name: string, scene: BABYLON.Scene);
  85811. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  85812. AddAttribute(name: string): CustomMaterial;
  85813. Fragment_Begin(shaderPart: string): CustomMaterial;
  85814. Fragment_Definitions(shaderPart: string): CustomMaterial;
  85815. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  85816. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  85817. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  85818. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  85819. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  85820. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  85821. Vertex_Begin(shaderPart: string): CustomMaterial;
  85822. Vertex_Definitions(shaderPart: string): CustomMaterial;
  85823. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  85824. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  85825. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  85826. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  85827. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  85828. }
  85829. }
  85830. declare module BABYLON {
  85831. export class ShaderAlebdoParts {
  85832. constructor();
  85833. Fragment_Begin: string;
  85834. Fragment_Definitions: string;
  85835. Fragment_MainBegin: string;
  85836. Fragment_Custom_Albedo: string;
  85837. Fragment_Before_Lights: string;
  85838. Fragment_Custom_MetallicRoughness: string;
  85839. Fragment_Custom_MicroSurface: string;
  85840. Fragment_Before_Fog: string;
  85841. Fragment_Custom_Alpha: string;
  85842. Fragment_Before_FragColor: string;
  85843. Vertex_Begin: string;
  85844. Vertex_Definitions: string;
  85845. Vertex_MainBegin: string;
  85846. Vertex_Before_PositionUpdated: string;
  85847. Vertex_Before_NormalUpdated: string;
  85848. Vertex_After_WorldPosComputed: string;
  85849. Vertex_MainEnd: string;
  85850. }
  85851. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  85852. static ShaderIndexer: number;
  85853. CustomParts: ShaderAlebdoParts;
  85854. _isCreatedShader: boolean;
  85855. _createdShaderName: string;
  85856. _customUniform: string[];
  85857. _newUniforms: string[];
  85858. _newUniformInstances: {
  85859. [name: string]: any;
  85860. };
  85861. _newSamplerInstances: {
  85862. [name: string]: BABYLON.Texture;
  85863. };
  85864. _customAttributes: string[];
  85865. FragmentShader: string;
  85866. VertexShader: string;
  85867. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  85868. ReviewUniform(name: string, arr: string[]): string[];
  85869. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  85870. constructor(name: string, scene: BABYLON.Scene);
  85871. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  85872. AddAttribute(name: string): PBRCustomMaterial;
  85873. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  85874. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  85875. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  85876. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  85877. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  85878. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  85879. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  85880. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  85881. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  85882. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  85883. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  85884. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  85885. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  85886. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  85887. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  85888. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  85889. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  85890. }
  85891. }
  85892. declare module BABYLON {
  85893. /** @hidden */
  85894. export var firePixelShader: {
  85895. name: string;
  85896. shader: string;
  85897. };
  85898. }
  85899. declare module BABYLON {
  85900. /** @hidden */
  85901. export var fireVertexShader: {
  85902. name: string;
  85903. shader: string;
  85904. };
  85905. }
  85906. declare module BABYLON {
  85907. export class FireMaterial extends BABYLON.PushMaterial {
  85908. private _diffuseTexture;
  85909. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  85910. private _distortionTexture;
  85911. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  85912. private _opacityTexture;
  85913. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  85914. diffuseColor: BABYLON.Color3;
  85915. speed: number;
  85916. private _scaledDiffuse;
  85917. private _lastTime;
  85918. constructor(name: string, scene: BABYLON.Scene);
  85919. needAlphaBlending(): boolean;
  85920. needAlphaTesting(): boolean;
  85921. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85922. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85923. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85924. getAnimatables(): BABYLON.IAnimatable[];
  85925. getActiveTextures(): BABYLON.BaseTexture[];
  85926. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85927. getClassName(): string;
  85928. dispose(forceDisposeEffect?: boolean): void;
  85929. clone(name: string): FireMaterial;
  85930. serialize(): any;
  85931. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  85932. }
  85933. }
  85934. declare module BABYLON {
  85935. /** @hidden */
  85936. export var furPixelShader: {
  85937. name: string;
  85938. shader: string;
  85939. };
  85940. }
  85941. declare module BABYLON {
  85942. /** @hidden */
  85943. export var furVertexShader: {
  85944. name: string;
  85945. shader: string;
  85946. };
  85947. }
  85948. declare module BABYLON {
  85949. export class FurMaterial extends BABYLON.PushMaterial {
  85950. private _diffuseTexture;
  85951. diffuseTexture: BABYLON.BaseTexture;
  85952. private _heightTexture;
  85953. heightTexture: BABYLON.BaseTexture;
  85954. diffuseColor: BABYLON.Color3;
  85955. furLength: number;
  85956. furAngle: number;
  85957. furColor: BABYLON.Color3;
  85958. furOffset: number;
  85959. furSpacing: number;
  85960. furGravity: BABYLON.Vector3;
  85961. furSpeed: number;
  85962. furDensity: number;
  85963. furOcclusion: number;
  85964. furTexture: BABYLON.DynamicTexture;
  85965. private _disableLighting;
  85966. disableLighting: boolean;
  85967. private _maxSimultaneousLights;
  85968. maxSimultaneousLights: number;
  85969. highLevelFur: boolean;
  85970. _meshes: BABYLON.AbstractMesh[];
  85971. private _furTime;
  85972. constructor(name: string, scene: BABYLON.Scene);
  85973. get furTime(): number;
  85974. set furTime(furTime: number);
  85975. needAlphaBlending(): boolean;
  85976. needAlphaTesting(): boolean;
  85977. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85978. updateFur(): void;
  85979. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85980. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85981. getAnimatables(): BABYLON.IAnimatable[];
  85982. getActiveTextures(): BABYLON.BaseTexture[];
  85983. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85984. dispose(forceDisposeEffect?: boolean): void;
  85985. clone(name: string): FurMaterial;
  85986. serialize(): any;
  85987. getClassName(): string;
  85988. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  85989. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  85990. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  85991. }
  85992. }
  85993. declare module BABYLON {
  85994. /** @hidden */
  85995. export var gradientPixelShader: {
  85996. name: string;
  85997. shader: string;
  85998. };
  85999. }
  86000. declare module BABYLON {
  86001. /** @hidden */
  86002. export var gradientVertexShader: {
  86003. name: string;
  86004. shader: string;
  86005. };
  86006. }
  86007. declare module BABYLON {
  86008. export class GradientMaterial extends BABYLON.PushMaterial {
  86009. private _maxSimultaneousLights;
  86010. maxSimultaneousLights: number;
  86011. topColor: BABYLON.Color3;
  86012. topColorAlpha: number;
  86013. bottomColor: BABYLON.Color3;
  86014. bottomColorAlpha: number;
  86015. offset: number;
  86016. scale: number;
  86017. smoothness: number;
  86018. private _disableLighting;
  86019. disableLighting: boolean;
  86020. constructor(name: string, scene: BABYLON.Scene);
  86021. needAlphaBlending(): boolean;
  86022. needAlphaTesting(): boolean;
  86023. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86024. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86025. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86026. getAnimatables(): BABYLON.IAnimatable[];
  86027. dispose(forceDisposeEffect?: boolean): void;
  86028. clone(name: string): GradientMaterial;
  86029. serialize(): any;
  86030. getClassName(): string;
  86031. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  86032. }
  86033. }
  86034. declare module BABYLON {
  86035. /** @hidden */
  86036. export var gridPixelShader: {
  86037. name: string;
  86038. shader: string;
  86039. };
  86040. }
  86041. declare module BABYLON {
  86042. /** @hidden */
  86043. export var gridVertexShader: {
  86044. name: string;
  86045. shader: string;
  86046. };
  86047. }
  86048. declare module BABYLON {
  86049. /**
  86050. * The grid materials allows you to wrap any shape with a grid.
  86051. * Colors are customizable.
  86052. */
  86053. export class GridMaterial extends BABYLON.PushMaterial {
  86054. /**
  86055. * Main color of the grid (e.g. between lines)
  86056. */
  86057. mainColor: BABYLON.Color3;
  86058. /**
  86059. * Color of the grid lines.
  86060. */
  86061. lineColor: BABYLON.Color3;
  86062. /**
  86063. * The scale of the grid compared to unit.
  86064. */
  86065. gridRatio: number;
  86066. /**
  86067. * Allows setting an offset for the grid lines.
  86068. */
  86069. gridOffset: BABYLON.Vector3;
  86070. /**
  86071. * The frequency of thicker lines.
  86072. */
  86073. majorUnitFrequency: number;
  86074. /**
  86075. * The visibility of minor units in the grid.
  86076. */
  86077. minorUnitVisibility: number;
  86078. /**
  86079. * The grid opacity outside of the lines.
  86080. */
  86081. opacity: number;
  86082. /**
  86083. * Determine RBG output is premultiplied by alpha value.
  86084. */
  86085. preMultiplyAlpha: boolean;
  86086. private _opacityTexture;
  86087. opacityTexture: BABYLON.BaseTexture;
  86088. private _gridControl;
  86089. /**
  86090. * constructor
  86091. * @param name The name given to the material in order to identify it afterwards.
  86092. * @param scene The scene the material is used in.
  86093. */
  86094. constructor(name: string, scene: BABYLON.Scene);
  86095. /**
  86096. * Returns wehter or not the grid requires alpha blending.
  86097. */
  86098. needAlphaBlending(): boolean;
  86099. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  86100. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86101. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86102. /**
  86103. * Dispose the material and its associated resources.
  86104. * @param forceDisposeEffect will also dispose the used effect when true
  86105. */
  86106. dispose(forceDisposeEffect?: boolean): void;
  86107. clone(name: string): GridMaterial;
  86108. serialize(): any;
  86109. getClassName(): string;
  86110. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  86111. }
  86112. }
  86113. declare module BABYLON {
  86114. /** @hidden */
  86115. export var lavaPixelShader: {
  86116. name: string;
  86117. shader: string;
  86118. };
  86119. }
  86120. declare module BABYLON {
  86121. /** @hidden */
  86122. export var lavaVertexShader: {
  86123. name: string;
  86124. shader: string;
  86125. };
  86126. }
  86127. declare module BABYLON {
  86128. export class LavaMaterial extends BABYLON.PushMaterial {
  86129. private _diffuseTexture;
  86130. diffuseTexture: BABYLON.BaseTexture;
  86131. noiseTexture: BABYLON.BaseTexture;
  86132. fogColor: BABYLON.Color3;
  86133. speed: number;
  86134. movingSpeed: number;
  86135. lowFrequencySpeed: number;
  86136. fogDensity: number;
  86137. private _lastTime;
  86138. diffuseColor: BABYLON.Color3;
  86139. private _disableLighting;
  86140. disableLighting: boolean;
  86141. private _unlit;
  86142. unlit: boolean;
  86143. private _maxSimultaneousLights;
  86144. maxSimultaneousLights: number;
  86145. private _scaledDiffuse;
  86146. constructor(name: string, scene: BABYLON.Scene);
  86147. needAlphaBlending(): boolean;
  86148. needAlphaTesting(): boolean;
  86149. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86150. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86151. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86152. getAnimatables(): BABYLON.IAnimatable[];
  86153. getActiveTextures(): BABYLON.BaseTexture[];
  86154. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86155. dispose(forceDisposeEffect?: boolean): void;
  86156. clone(name: string): LavaMaterial;
  86157. serialize(): any;
  86158. getClassName(): string;
  86159. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  86160. }
  86161. }
  86162. declare module BABYLON {
  86163. /** @hidden */
  86164. export var mixPixelShader: {
  86165. name: string;
  86166. shader: string;
  86167. };
  86168. }
  86169. declare module BABYLON {
  86170. /** @hidden */
  86171. export var mixVertexShader: {
  86172. name: string;
  86173. shader: string;
  86174. };
  86175. }
  86176. declare module BABYLON {
  86177. export class MixMaterial extends BABYLON.PushMaterial {
  86178. /**
  86179. * Mix textures
  86180. */
  86181. private _mixTexture1;
  86182. mixTexture1: BABYLON.BaseTexture;
  86183. private _mixTexture2;
  86184. mixTexture2: BABYLON.BaseTexture;
  86185. /**
  86186. * Diffuse textures
  86187. */
  86188. private _diffuseTexture1;
  86189. diffuseTexture1: BABYLON.Texture;
  86190. private _diffuseTexture2;
  86191. diffuseTexture2: BABYLON.Texture;
  86192. private _diffuseTexture3;
  86193. diffuseTexture3: BABYLON.Texture;
  86194. private _diffuseTexture4;
  86195. diffuseTexture4: BABYLON.Texture;
  86196. private _diffuseTexture5;
  86197. diffuseTexture5: BABYLON.Texture;
  86198. private _diffuseTexture6;
  86199. diffuseTexture6: BABYLON.Texture;
  86200. private _diffuseTexture7;
  86201. diffuseTexture7: BABYLON.Texture;
  86202. private _diffuseTexture8;
  86203. diffuseTexture8: BABYLON.Texture;
  86204. /**
  86205. * Uniforms
  86206. */
  86207. diffuseColor: BABYLON.Color3;
  86208. specularColor: BABYLON.Color3;
  86209. specularPower: number;
  86210. private _disableLighting;
  86211. disableLighting: boolean;
  86212. private _maxSimultaneousLights;
  86213. maxSimultaneousLights: number;
  86214. constructor(name: string, scene: BABYLON.Scene);
  86215. needAlphaBlending(): boolean;
  86216. needAlphaTesting(): boolean;
  86217. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86218. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86219. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86220. getAnimatables(): BABYLON.IAnimatable[];
  86221. getActiveTextures(): BABYLON.BaseTexture[];
  86222. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86223. dispose(forceDisposeEffect?: boolean): void;
  86224. clone(name: string): MixMaterial;
  86225. serialize(): any;
  86226. getClassName(): string;
  86227. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  86228. }
  86229. }
  86230. declare module BABYLON {
  86231. /** @hidden */
  86232. export var normalPixelShader: {
  86233. name: string;
  86234. shader: string;
  86235. };
  86236. }
  86237. declare module BABYLON {
  86238. /** @hidden */
  86239. export var normalVertexShader: {
  86240. name: string;
  86241. shader: string;
  86242. };
  86243. }
  86244. declare module BABYLON {
  86245. export class NormalMaterial extends BABYLON.PushMaterial {
  86246. private _diffuseTexture;
  86247. diffuseTexture: BABYLON.BaseTexture;
  86248. diffuseColor: BABYLON.Color3;
  86249. private _disableLighting;
  86250. disableLighting: boolean;
  86251. private _maxSimultaneousLights;
  86252. maxSimultaneousLights: number;
  86253. constructor(name: string, scene: BABYLON.Scene);
  86254. needAlphaBlending(): boolean;
  86255. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  86256. needAlphaTesting(): boolean;
  86257. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86258. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86259. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86260. getAnimatables(): BABYLON.IAnimatable[];
  86261. getActiveTextures(): BABYLON.BaseTexture[];
  86262. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86263. dispose(forceDisposeEffect?: boolean): void;
  86264. clone(name: string): NormalMaterial;
  86265. serialize(): any;
  86266. getClassName(): string;
  86267. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  86268. }
  86269. }
  86270. declare module BABYLON {
  86271. /** @hidden */
  86272. export var shadowOnlyPixelShader: {
  86273. name: string;
  86274. shader: string;
  86275. };
  86276. }
  86277. declare module BABYLON {
  86278. /** @hidden */
  86279. export var shadowOnlyVertexShader: {
  86280. name: string;
  86281. shader: string;
  86282. };
  86283. }
  86284. declare module BABYLON {
  86285. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  86286. private _activeLight;
  86287. private _needAlphaBlending;
  86288. constructor(name: string, scene: BABYLON.Scene);
  86289. shadowColor: BABYLON.Color3;
  86290. needAlphaBlending(): boolean;
  86291. needAlphaTesting(): boolean;
  86292. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86293. get activeLight(): BABYLON.IShadowLight;
  86294. set activeLight(light: BABYLON.IShadowLight);
  86295. private _getFirstShadowLightForMesh;
  86296. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86297. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86298. clone(name: string): ShadowOnlyMaterial;
  86299. serialize(): any;
  86300. getClassName(): string;
  86301. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  86302. }
  86303. }
  86304. declare module BABYLON {
  86305. /** @hidden */
  86306. export var simplePixelShader: {
  86307. name: string;
  86308. shader: string;
  86309. };
  86310. }
  86311. declare module BABYLON {
  86312. /** @hidden */
  86313. export var simpleVertexShader: {
  86314. name: string;
  86315. shader: string;
  86316. };
  86317. }
  86318. declare module BABYLON {
  86319. export class SimpleMaterial extends BABYLON.PushMaterial {
  86320. private _diffuseTexture;
  86321. diffuseTexture: BABYLON.BaseTexture;
  86322. diffuseColor: BABYLON.Color3;
  86323. private _disableLighting;
  86324. disableLighting: boolean;
  86325. private _maxSimultaneousLights;
  86326. maxSimultaneousLights: number;
  86327. constructor(name: string, scene: BABYLON.Scene);
  86328. needAlphaBlending(): boolean;
  86329. needAlphaTesting(): boolean;
  86330. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86331. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86332. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86333. getAnimatables(): BABYLON.IAnimatable[];
  86334. getActiveTextures(): BABYLON.BaseTexture[];
  86335. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86336. dispose(forceDisposeEffect?: boolean): void;
  86337. clone(name: string): SimpleMaterial;
  86338. serialize(): any;
  86339. getClassName(): string;
  86340. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  86341. }
  86342. }
  86343. declare module BABYLON {
  86344. /** @hidden */
  86345. export var skyPixelShader: {
  86346. name: string;
  86347. shader: string;
  86348. };
  86349. }
  86350. declare module BABYLON {
  86351. /** @hidden */
  86352. export var skyVertexShader: {
  86353. name: string;
  86354. shader: string;
  86355. };
  86356. }
  86357. declare module BABYLON {
  86358. /**
  86359. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  86360. * @see https://doc.babylonjs.com/extensions/sky
  86361. */
  86362. export class SkyMaterial extends BABYLON.PushMaterial {
  86363. /**
  86364. * Defines the overall luminance of sky in interval ]0, 1[.
  86365. */
  86366. luminance: number;
  86367. /**
  86368. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  86369. */
  86370. turbidity: number;
  86371. /**
  86372. * Defines the sky appearance (light intensity).
  86373. */
  86374. rayleigh: number;
  86375. /**
  86376. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  86377. */
  86378. mieCoefficient: number;
  86379. /**
  86380. * Defines the amount of haze particles following the Mie scattering theory.
  86381. */
  86382. mieDirectionalG: number;
  86383. /**
  86384. * Defines the distance of the sun according to the active scene camera.
  86385. */
  86386. distance: number;
  86387. /**
  86388. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  86389. * "inclined".
  86390. */
  86391. inclination: number;
  86392. /**
  86393. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  86394. * an object direction and a reference direction.
  86395. */
  86396. azimuth: number;
  86397. /**
  86398. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  86399. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  86400. */
  86401. sunPosition: BABYLON.Vector3;
  86402. /**
  86403. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  86404. * .sunPosition property.
  86405. */
  86406. useSunPosition: boolean;
  86407. /**
  86408. * Defines an offset vector used to get a horizon offset.
  86409. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  86410. */
  86411. cameraOffset: BABYLON.Vector3;
  86412. private _cameraPosition;
  86413. /**
  86414. * Instantiates a new sky material.
  86415. * This material allows to create dynamic and texture free
  86416. * effects for skyboxes by taking care of the atmosphere state.
  86417. * @see https://doc.babylonjs.com/extensions/sky
  86418. * @param name Define the name of the material in the scene
  86419. * @param scene Define the scene the material belong to
  86420. */
  86421. constructor(name: string, scene: BABYLON.Scene);
  86422. /**
  86423. * Specifies if the material will require alpha blending
  86424. * @returns a boolean specifying if alpha blending is needed
  86425. */
  86426. needAlphaBlending(): boolean;
  86427. /**
  86428. * Specifies if this material should be rendered in alpha test mode
  86429. * @returns false as the sky material doesn't need alpha testing.
  86430. */
  86431. needAlphaTesting(): boolean;
  86432. /**
  86433. * Get the texture used for alpha test purpose.
  86434. * @returns null as the sky material has no texture.
  86435. */
  86436. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86437. /**
  86438. * Get if the submesh is ready to be used and all its information available.
  86439. * Child classes can use it to update shaders
  86440. * @param mesh defines the mesh to check
  86441. * @param subMesh defines which submesh to check
  86442. * @param useInstances specifies that instances should be used
  86443. * @returns a boolean indicating that the submesh is ready or not
  86444. */
  86445. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86446. /**
  86447. * Binds the submesh to this material by preparing the effect and shader to draw
  86448. * @param world defines the world transformation matrix
  86449. * @param mesh defines the mesh containing the submesh
  86450. * @param subMesh defines the submesh to bind the material to
  86451. */
  86452. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86453. /**
  86454. * Get the list of animatables in the material.
  86455. * @returns the list of animatables object used in the material
  86456. */
  86457. getAnimatables(): BABYLON.IAnimatable[];
  86458. /**
  86459. * Disposes the material
  86460. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  86461. */
  86462. dispose(forceDisposeEffect?: boolean): void;
  86463. /**
  86464. * Makes a duplicate of the material, and gives it a new name
  86465. * @param name defines the new name for the duplicated material
  86466. * @returns the cloned material
  86467. */
  86468. clone(name: string): SkyMaterial;
  86469. /**
  86470. * Serializes this material in a JSON representation
  86471. * @returns the serialized material object
  86472. */
  86473. serialize(): any;
  86474. /**
  86475. * Gets the current class name of the material e.g. "SkyMaterial"
  86476. * Mainly use in serialization.
  86477. * @returns the class name
  86478. */
  86479. getClassName(): string;
  86480. /**
  86481. * Creates a sky material from parsed material data
  86482. * @param source defines the JSON representation of the material
  86483. * @param scene defines the hosting scene
  86484. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  86485. * @returns a new sky material
  86486. */
  86487. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  86488. }
  86489. }
  86490. declare module BABYLON {
  86491. /** @hidden */
  86492. export var terrainPixelShader: {
  86493. name: string;
  86494. shader: string;
  86495. };
  86496. }
  86497. declare module BABYLON {
  86498. /** @hidden */
  86499. export var terrainVertexShader: {
  86500. name: string;
  86501. shader: string;
  86502. };
  86503. }
  86504. declare module BABYLON {
  86505. export class TerrainMaterial extends BABYLON.PushMaterial {
  86506. private _mixTexture;
  86507. mixTexture: BABYLON.BaseTexture;
  86508. private _diffuseTexture1;
  86509. diffuseTexture1: BABYLON.Texture;
  86510. private _diffuseTexture2;
  86511. diffuseTexture2: BABYLON.Texture;
  86512. private _diffuseTexture3;
  86513. diffuseTexture3: BABYLON.Texture;
  86514. private _bumpTexture1;
  86515. bumpTexture1: BABYLON.Texture;
  86516. private _bumpTexture2;
  86517. bumpTexture2: BABYLON.Texture;
  86518. private _bumpTexture3;
  86519. bumpTexture3: BABYLON.Texture;
  86520. diffuseColor: BABYLON.Color3;
  86521. specularColor: BABYLON.Color3;
  86522. specularPower: number;
  86523. private _disableLighting;
  86524. disableLighting: boolean;
  86525. private _maxSimultaneousLights;
  86526. maxSimultaneousLights: number;
  86527. constructor(name: string, scene: BABYLON.Scene);
  86528. needAlphaBlending(): boolean;
  86529. needAlphaTesting(): boolean;
  86530. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86531. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86532. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86533. getAnimatables(): BABYLON.IAnimatable[];
  86534. getActiveTextures(): BABYLON.BaseTexture[];
  86535. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86536. dispose(forceDisposeEffect?: boolean): void;
  86537. clone(name: string): TerrainMaterial;
  86538. serialize(): any;
  86539. getClassName(): string;
  86540. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  86541. }
  86542. }
  86543. declare module BABYLON {
  86544. /** @hidden */
  86545. export var triplanarPixelShader: {
  86546. name: string;
  86547. shader: string;
  86548. };
  86549. }
  86550. declare module BABYLON {
  86551. /** @hidden */
  86552. export var triplanarVertexShader: {
  86553. name: string;
  86554. shader: string;
  86555. };
  86556. }
  86557. declare module BABYLON {
  86558. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  86559. mixTexture: BABYLON.BaseTexture;
  86560. private _diffuseTextureX;
  86561. diffuseTextureX: BABYLON.BaseTexture;
  86562. private _diffuseTextureY;
  86563. diffuseTextureY: BABYLON.BaseTexture;
  86564. private _diffuseTextureZ;
  86565. diffuseTextureZ: BABYLON.BaseTexture;
  86566. private _normalTextureX;
  86567. normalTextureX: BABYLON.BaseTexture;
  86568. private _normalTextureY;
  86569. normalTextureY: BABYLON.BaseTexture;
  86570. private _normalTextureZ;
  86571. normalTextureZ: BABYLON.BaseTexture;
  86572. tileSize: number;
  86573. diffuseColor: BABYLON.Color3;
  86574. specularColor: BABYLON.Color3;
  86575. specularPower: number;
  86576. private _disableLighting;
  86577. disableLighting: boolean;
  86578. private _maxSimultaneousLights;
  86579. maxSimultaneousLights: number;
  86580. constructor(name: string, scene: BABYLON.Scene);
  86581. needAlphaBlending(): boolean;
  86582. needAlphaTesting(): boolean;
  86583. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86584. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86585. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86586. getAnimatables(): BABYLON.IAnimatable[];
  86587. getActiveTextures(): BABYLON.BaseTexture[];
  86588. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86589. dispose(forceDisposeEffect?: boolean): void;
  86590. clone(name: string): TriPlanarMaterial;
  86591. serialize(): any;
  86592. getClassName(): string;
  86593. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  86594. }
  86595. }
  86596. declare module BABYLON {
  86597. /** @hidden */
  86598. export var waterPixelShader: {
  86599. name: string;
  86600. shader: string;
  86601. };
  86602. }
  86603. declare module BABYLON {
  86604. /** @hidden */
  86605. export var waterVertexShader: {
  86606. name: string;
  86607. shader: string;
  86608. };
  86609. }
  86610. declare module BABYLON {
  86611. export class WaterMaterial extends BABYLON.PushMaterial {
  86612. renderTargetSize: BABYLON.Vector2;
  86613. private _bumpTexture;
  86614. bumpTexture: BABYLON.BaseTexture;
  86615. diffuseColor: BABYLON.Color3;
  86616. specularColor: BABYLON.Color3;
  86617. specularPower: number;
  86618. private _disableLighting;
  86619. disableLighting: boolean;
  86620. private _maxSimultaneousLights;
  86621. maxSimultaneousLights: number;
  86622. /**
  86623. * @param {number}: Represents the wind force
  86624. */
  86625. windForce: number;
  86626. /**
  86627. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  86628. */
  86629. windDirection: BABYLON.Vector2;
  86630. /**
  86631. * @param {number}: Wave height, represents the height of the waves
  86632. */
  86633. waveHeight: number;
  86634. /**
  86635. * @param {number}: Bump height, represents the bump height related to the bump map
  86636. */
  86637. bumpHeight: number;
  86638. /**
  86639. * @param {boolean}: Add a smaller moving bump to less steady waves.
  86640. */
  86641. private _bumpSuperimpose;
  86642. bumpSuperimpose: boolean;
  86643. /**
  86644. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  86645. */
  86646. private _fresnelSeparate;
  86647. fresnelSeparate: boolean;
  86648. /**
  86649. * @param {boolean}: bump Waves modify the reflection.
  86650. */
  86651. private _bumpAffectsReflection;
  86652. bumpAffectsReflection: boolean;
  86653. /**
  86654. * @param {number}: The water color blended with the refraction (near)
  86655. */
  86656. waterColor: BABYLON.Color3;
  86657. /**
  86658. * @param {number}: The blend factor related to the water color
  86659. */
  86660. colorBlendFactor: number;
  86661. /**
  86662. * @param {number}: The water color blended with the reflection (far)
  86663. */
  86664. waterColor2: BABYLON.Color3;
  86665. /**
  86666. * @param {number}: The blend factor related to the water color (reflection, far)
  86667. */
  86668. colorBlendFactor2: number;
  86669. /**
  86670. * @param {number}: Represents the maximum length of a wave
  86671. */
  86672. waveLength: number;
  86673. /**
  86674. * @param {number}: Defines the waves speed
  86675. */
  86676. waveSpeed: number;
  86677. /**
  86678. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  86679. * will avoid calculating useless pixels in the pixel shader of the water material.
  86680. */
  86681. disableClipPlane: boolean;
  86682. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  86683. private _mesh;
  86684. private _refractionRTT;
  86685. private _reflectionRTT;
  86686. private _reflectionTransform;
  86687. private _lastTime;
  86688. private _lastDeltaTime;
  86689. private _useLogarithmicDepth;
  86690. private _waitingRenderList;
  86691. private _imageProcessingConfiguration;
  86692. private _imageProcessingObserver;
  86693. /**
  86694. * Gets a boolean indicating that current material needs to register RTT
  86695. */
  86696. get hasRenderTargetTextures(): boolean;
  86697. /**
  86698. * Constructor
  86699. */
  86700. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  86701. get useLogarithmicDepth(): boolean;
  86702. set useLogarithmicDepth(value: boolean);
  86703. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  86704. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  86705. addToRenderList(node: any): void;
  86706. enableRenderTargets(enable: boolean): void;
  86707. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  86708. get renderTargetsEnabled(): boolean;
  86709. needAlphaBlending(): boolean;
  86710. needAlphaTesting(): boolean;
  86711. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86712. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86713. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86714. private _createRenderTargets;
  86715. getAnimatables(): BABYLON.IAnimatable[];
  86716. getActiveTextures(): BABYLON.BaseTexture[];
  86717. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86718. dispose(forceDisposeEffect?: boolean): void;
  86719. clone(name: string): WaterMaterial;
  86720. serialize(): any;
  86721. getClassName(): string;
  86722. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  86723. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  86724. }
  86725. }
  86726. declare module BABYLON {
  86727. /** @hidden */
  86728. export var asciiartPixelShader: {
  86729. name: string;
  86730. shader: string;
  86731. };
  86732. }
  86733. declare module BABYLON {
  86734. /**
  86735. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  86736. *
  86737. * It basically takes care rendering the font front the given font size to a texture.
  86738. * This is used later on in the postprocess.
  86739. */
  86740. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  86741. private _font;
  86742. private _text;
  86743. private _charSize;
  86744. /**
  86745. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  86746. */
  86747. get charSize(): number;
  86748. /**
  86749. * Create a new instance of the Ascii Art FontTexture class
  86750. * @param name the name of the texture
  86751. * @param font the font to use, use the W3C CSS notation
  86752. * @param text the caracter set to use in the rendering.
  86753. * @param scene the scene that owns the texture
  86754. */
  86755. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  86756. /**
  86757. * Gets the max char width of a font.
  86758. * @param font the font to use, use the W3C CSS notation
  86759. * @return the max char width
  86760. */
  86761. private getFontWidth;
  86762. /**
  86763. * Gets the max char height of a font.
  86764. * @param font the font to use, use the W3C CSS notation
  86765. * @return the max char height
  86766. */
  86767. private getFontHeight;
  86768. /**
  86769. * Clones the current AsciiArtTexture.
  86770. * @return the clone of the texture.
  86771. */
  86772. clone(): AsciiArtFontTexture;
  86773. /**
  86774. * Parses a json object representing the texture and returns an instance of it.
  86775. * @param source the source JSON representation
  86776. * @param scene the scene to create the texture for
  86777. * @return the parsed texture
  86778. */
  86779. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  86780. }
  86781. /**
  86782. * Option available in the Ascii Art Post Process.
  86783. */
  86784. export interface IAsciiArtPostProcessOptions {
  86785. /**
  86786. * The font to use following the w3c font definition.
  86787. */
  86788. font?: string;
  86789. /**
  86790. * The character set to use in the postprocess.
  86791. */
  86792. characterSet?: string;
  86793. /**
  86794. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  86795. * This number is defined between 0 and 1;
  86796. */
  86797. mixToTile?: number;
  86798. /**
  86799. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  86800. * This number is defined between 0 and 1;
  86801. */
  86802. mixToNormal?: number;
  86803. }
  86804. /**
  86805. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  86806. *
  86807. * Simmply add it to your scene and let the nerd that lives in you have fun.
  86808. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  86809. */
  86810. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  86811. /**
  86812. * The font texture used to render the char in the post process.
  86813. */
  86814. private _asciiArtFontTexture;
  86815. /**
  86816. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  86817. * This number is defined between 0 and 1;
  86818. */
  86819. mixToTile: number;
  86820. /**
  86821. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  86822. * This number is defined between 0 and 1;
  86823. */
  86824. mixToNormal: number;
  86825. /**
  86826. * Instantiates a new Ascii Art Post Process.
  86827. * @param name the name to give to the postprocess
  86828. * @camera the camera to apply the post process to.
  86829. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  86830. */
  86831. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  86832. }
  86833. }
  86834. declare module BABYLON {
  86835. /** @hidden */
  86836. export var digitalrainPixelShader: {
  86837. name: string;
  86838. shader: string;
  86839. };
  86840. }
  86841. declare module BABYLON {
  86842. /**
  86843. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  86844. *
  86845. * It basically takes care rendering the font front the given font size to a texture.
  86846. * This is used later on in the postprocess.
  86847. */
  86848. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  86849. private _font;
  86850. private _text;
  86851. private _charSize;
  86852. /**
  86853. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  86854. */
  86855. get charSize(): number;
  86856. /**
  86857. * Create a new instance of the Digital Rain FontTexture class
  86858. * @param name the name of the texture
  86859. * @param font the font to use, use the W3C CSS notation
  86860. * @param text the caracter set to use in the rendering.
  86861. * @param scene the scene that owns the texture
  86862. */
  86863. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  86864. /**
  86865. * Gets the max char width of a font.
  86866. * @param font the font to use, use the W3C CSS notation
  86867. * @return the max char width
  86868. */
  86869. private getFontWidth;
  86870. /**
  86871. * Gets the max char height of a font.
  86872. * @param font the font to use, use the W3C CSS notation
  86873. * @return the max char height
  86874. */
  86875. private getFontHeight;
  86876. /**
  86877. * Clones the current DigitalRainFontTexture.
  86878. * @return the clone of the texture.
  86879. */
  86880. clone(): DigitalRainFontTexture;
  86881. /**
  86882. * Parses a json object representing the texture and returns an instance of it.
  86883. * @param source the source JSON representation
  86884. * @param scene the scene to create the texture for
  86885. * @return the parsed texture
  86886. */
  86887. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  86888. }
  86889. /**
  86890. * Option available in the Digital Rain Post Process.
  86891. */
  86892. export interface IDigitalRainPostProcessOptions {
  86893. /**
  86894. * The font to use following the w3c font definition.
  86895. */
  86896. font?: string;
  86897. /**
  86898. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  86899. * This number is defined between 0 and 1;
  86900. */
  86901. mixToTile?: number;
  86902. /**
  86903. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  86904. * This number is defined between 0 and 1;
  86905. */
  86906. mixToNormal?: number;
  86907. }
  86908. /**
  86909. * DigitalRainPostProcess helps rendering everithing in digital rain.
  86910. *
  86911. * Simmply add it to your scene and let the nerd that lives in you have fun.
  86912. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  86913. */
  86914. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  86915. /**
  86916. * The font texture used to render the char in the post process.
  86917. */
  86918. private _digitalRainFontTexture;
  86919. /**
  86920. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  86921. * This number is defined between 0 and 1;
  86922. */
  86923. mixToTile: number;
  86924. /**
  86925. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  86926. * This number is defined between 0 and 1;
  86927. */
  86928. mixToNormal: number;
  86929. /**
  86930. * Instantiates a new Digital Rain Post Process.
  86931. * @param name the name to give to the postprocess
  86932. * @camera the camera to apply the post process to.
  86933. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  86934. */
  86935. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  86936. }
  86937. }
  86938. declare module BABYLON {
  86939. /** @hidden */
  86940. export var brickProceduralTexturePixelShader: {
  86941. name: string;
  86942. shader: string;
  86943. };
  86944. }
  86945. declare module BABYLON {
  86946. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  86947. private _numberOfBricksHeight;
  86948. private _numberOfBricksWidth;
  86949. private _jointColor;
  86950. private _brickColor;
  86951. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86952. updateShaderUniforms(): void;
  86953. get numberOfBricksHeight(): number;
  86954. set numberOfBricksHeight(value: number);
  86955. get numberOfBricksWidth(): number;
  86956. set numberOfBricksWidth(value: number);
  86957. get jointColor(): BABYLON.Color3;
  86958. set jointColor(value: BABYLON.Color3);
  86959. get brickColor(): BABYLON.Color3;
  86960. set brickColor(value: BABYLON.Color3);
  86961. /**
  86962. * Serializes this brick procedural texture
  86963. * @returns a serialized brick procedural texture object
  86964. */
  86965. serialize(): any;
  86966. /**
  86967. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  86968. * @param parsedTexture defines parsed texture data
  86969. * @param scene defines the current scene
  86970. * @param rootUrl defines the root URL containing brick procedural texture information
  86971. * @returns a parsed Brick Procedural BABYLON.Texture
  86972. */
  86973. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  86974. }
  86975. }
  86976. declare module BABYLON {
  86977. /** @hidden */
  86978. export var cloudProceduralTexturePixelShader: {
  86979. name: string;
  86980. shader: string;
  86981. };
  86982. }
  86983. declare module BABYLON {
  86984. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  86985. private _skyColor;
  86986. private _cloudColor;
  86987. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86988. updateShaderUniforms(): void;
  86989. get skyColor(): BABYLON.Color4;
  86990. set skyColor(value: BABYLON.Color4);
  86991. get cloudColor(): BABYLON.Color4;
  86992. set cloudColor(value: BABYLON.Color4);
  86993. /**
  86994. * Serializes this cloud procedural texture
  86995. * @returns a serialized cloud procedural texture object
  86996. */
  86997. serialize(): any;
  86998. /**
  86999. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  87000. * @param parsedTexture defines parsed texture data
  87001. * @param scene defines the current scene
  87002. * @param rootUrl defines the root URL containing cloud procedural texture information
  87003. * @returns a parsed Cloud Procedural BABYLON.Texture
  87004. */
  87005. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  87006. }
  87007. }
  87008. declare module BABYLON {
  87009. /** @hidden */
  87010. export var fireProceduralTexturePixelShader: {
  87011. name: string;
  87012. shader: string;
  87013. };
  87014. }
  87015. declare module BABYLON {
  87016. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  87017. private _time;
  87018. private _speed;
  87019. private _autoGenerateTime;
  87020. private _fireColors;
  87021. private _alphaThreshold;
  87022. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87023. updateShaderUniforms(): void;
  87024. render(useCameraPostProcess?: boolean): void;
  87025. static get PurpleFireColors(): BABYLON.Color3[];
  87026. static get GreenFireColors(): BABYLON.Color3[];
  87027. static get RedFireColors(): BABYLON.Color3[];
  87028. static get BlueFireColors(): BABYLON.Color3[];
  87029. get autoGenerateTime(): boolean;
  87030. set autoGenerateTime(value: boolean);
  87031. get fireColors(): BABYLON.Color3[];
  87032. set fireColors(value: BABYLON.Color3[]);
  87033. get time(): number;
  87034. set time(value: number);
  87035. get speed(): BABYLON.Vector2;
  87036. set speed(value: BABYLON.Vector2);
  87037. get alphaThreshold(): number;
  87038. set alphaThreshold(value: number);
  87039. /**
  87040. * Serializes this fire procedural texture
  87041. * @returns a serialized fire procedural texture object
  87042. */
  87043. serialize(): any;
  87044. /**
  87045. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  87046. * @param parsedTexture defines parsed texture data
  87047. * @param scene defines the current scene
  87048. * @param rootUrl defines the root URL containing fire procedural texture information
  87049. * @returns a parsed Fire Procedural BABYLON.Texture
  87050. */
  87051. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  87052. }
  87053. }
  87054. declare module BABYLON {
  87055. /** @hidden */
  87056. export var grassProceduralTexturePixelShader: {
  87057. name: string;
  87058. shader: string;
  87059. };
  87060. }
  87061. declare module BABYLON {
  87062. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  87063. private _grassColors;
  87064. private _groundColor;
  87065. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87066. updateShaderUniforms(): void;
  87067. get grassColors(): BABYLON.Color3[];
  87068. set grassColors(value: BABYLON.Color3[]);
  87069. get groundColor(): BABYLON.Color3;
  87070. set groundColor(value: BABYLON.Color3);
  87071. /**
  87072. * Serializes this grass procedural texture
  87073. * @returns a serialized grass procedural texture object
  87074. */
  87075. serialize(): any;
  87076. /**
  87077. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  87078. * @param parsedTexture defines parsed texture data
  87079. * @param scene defines the current scene
  87080. * @param rootUrl defines the root URL containing grass procedural texture information
  87081. * @returns a parsed Grass Procedural BABYLON.Texture
  87082. */
  87083. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  87084. }
  87085. }
  87086. declare module BABYLON {
  87087. /** @hidden */
  87088. export var marbleProceduralTexturePixelShader: {
  87089. name: string;
  87090. shader: string;
  87091. };
  87092. }
  87093. declare module BABYLON {
  87094. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  87095. private _numberOfTilesHeight;
  87096. private _numberOfTilesWidth;
  87097. private _amplitude;
  87098. private _jointColor;
  87099. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87100. updateShaderUniforms(): void;
  87101. get numberOfTilesHeight(): number;
  87102. set numberOfTilesHeight(value: number);
  87103. get amplitude(): number;
  87104. set amplitude(value: number);
  87105. get numberOfTilesWidth(): number;
  87106. set numberOfTilesWidth(value: number);
  87107. get jointColor(): BABYLON.Color3;
  87108. set jointColor(value: BABYLON.Color3);
  87109. /**
  87110. * Serializes this marble procedural texture
  87111. * @returns a serialized marble procedural texture object
  87112. */
  87113. serialize(): any;
  87114. /**
  87115. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  87116. * @param parsedTexture defines parsed texture data
  87117. * @param scene defines the current scene
  87118. * @param rootUrl defines the root URL containing marble procedural texture information
  87119. * @returns a parsed Marble Procedural BABYLON.Texture
  87120. */
  87121. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  87122. }
  87123. }
  87124. declare module BABYLON {
  87125. /** @hidden */
  87126. export var normalMapProceduralTexturePixelShader: {
  87127. name: string;
  87128. shader: string;
  87129. };
  87130. }
  87131. declare module BABYLON {
  87132. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  87133. private _baseTexture;
  87134. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87135. updateShaderUniforms(): void;
  87136. render(useCameraPostProcess?: boolean): void;
  87137. resize(size: any, generateMipMaps: any): void;
  87138. get baseTexture(): BABYLON.Texture;
  87139. set baseTexture(texture: BABYLON.Texture);
  87140. /**
  87141. * Serializes this normal map procedural texture
  87142. * @returns a serialized normal map procedural texture object
  87143. */
  87144. serialize(): any;
  87145. /**
  87146. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  87147. * @param parsedTexture defines parsed texture data
  87148. * @param scene defines the current scene
  87149. * @param rootUrl defines the root URL containing normal map procedural texture information
  87150. * @returns a parsed Normal Map Procedural BABYLON.Texture
  87151. */
  87152. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  87153. }
  87154. }
  87155. declare module BABYLON {
  87156. /** @hidden */
  87157. export var perlinNoiseProceduralTexturePixelShader: {
  87158. name: string;
  87159. shader: string;
  87160. };
  87161. }
  87162. declare module BABYLON {
  87163. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  87164. time: number;
  87165. timeScale: number;
  87166. translationSpeed: number;
  87167. private _currentTranslation;
  87168. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87169. updateShaderUniforms(): void;
  87170. render(useCameraPostProcess?: boolean): void;
  87171. resize(size: any, generateMipMaps: any): void;
  87172. /**
  87173. * Serializes this perlin noise procedural texture
  87174. * @returns a serialized perlin noise procedural texture object
  87175. */
  87176. serialize(): any;
  87177. /**
  87178. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  87179. * @param parsedTexture defines parsed texture data
  87180. * @param scene defines the current scene
  87181. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  87182. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  87183. */
  87184. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  87185. }
  87186. }
  87187. declare module BABYLON {
  87188. /** @hidden */
  87189. export var roadProceduralTexturePixelShader: {
  87190. name: string;
  87191. shader: string;
  87192. };
  87193. }
  87194. declare module BABYLON {
  87195. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  87196. private _roadColor;
  87197. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87198. updateShaderUniforms(): void;
  87199. get roadColor(): BABYLON.Color3;
  87200. set roadColor(value: BABYLON.Color3);
  87201. /**
  87202. * Serializes this road procedural texture
  87203. * @returns a serialized road procedural texture object
  87204. */
  87205. serialize(): any;
  87206. /**
  87207. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  87208. * @param parsedTexture defines parsed texture data
  87209. * @param scene defines the current scene
  87210. * @param rootUrl defines the root URL containing road procedural texture information
  87211. * @returns a parsed Road Procedural BABYLON.Texture
  87212. */
  87213. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  87214. }
  87215. }
  87216. declare module BABYLON {
  87217. /** @hidden */
  87218. export var starfieldProceduralTexturePixelShader: {
  87219. name: string;
  87220. shader: string;
  87221. };
  87222. }
  87223. declare module BABYLON {
  87224. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  87225. private _time;
  87226. private _alpha;
  87227. private _beta;
  87228. private _zoom;
  87229. private _formuparam;
  87230. private _stepsize;
  87231. private _tile;
  87232. private _brightness;
  87233. private _darkmatter;
  87234. private _distfading;
  87235. private _saturation;
  87236. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87237. updateShaderUniforms(): void;
  87238. get time(): number;
  87239. set time(value: number);
  87240. get alpha(): number;
  87241. set alpha(value: number);
  87242. get beta(): number;
  87243. set beta(value: number);
  87244. get formuparam(): number;
  87245. set formuparam(value: number);
  87246. get stepsize(): number;
  87247. set stepsize(value: number);
  87248. get zoom(): number;
  87249. set zoom(value: number);
  87250. get tile(): number;
  87251. set tile(value: number);
  87252. get brightness(): number;
  87253. set brightness(value: number);
  87254. get darkmatter(): number;
  87255. set darkmatter(value: number);
  87256. get distfading(): number;
  87257. set distfading(value: number);
  87258. get saturation(): number;
  87259. set saturation(value: number);
  87260. /**
  87261. * Serializes this starfield procedural texture
  87262. * @returns a serialized starfield procedural texture object
  87263. */
  87264. serialize(): any;
  87265. /**
  87266. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  87267. * @param parsedTexture defines parsed texture data
  87268. * @param scene defines the current scene
  87269. * @param rootUrl defines the root URL containing startfield procedural texture information
  87270. * @returns a parsed Starfield Procedural BABYLON.Texture
  87271. */
  87272. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  87273. }
  87274. }
  87275. declare module BABYLON {
  87276. /** @hidden */
  87277. export var woodProceduralTexturePixelShader: {
  87278. name: string;
  87279. shader: string;
  87280. };
  87281. }
  87282. declare module BABYLON {
  87283. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  87284. private _ampScale;
  87285. private _woodColor;
  87286. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87287. updateShaderUniforms(): void;
  87288. get ampScale(): number;
  87289. set ampScale(value: number);
  87290. get woodColor(): BABYLON.Color3;
  87291. set woodColor(value: BABYLON.Color3);
  87292. /**
  87293. * Serializes this wood procedural texture
  87294. * @returns a serialized wood procedural texture object
  87295. */
  87296. serialize(): any;
  87297. /**
  87298. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  87299. * @param parsedTexture defines parsed texture data
  87300. * @param scene defines the current scene
  87301. * @param rootUrl defines the root URL containing wood procedural texture information
  87302. * @returns a parsed Wood Procedural BABYLON.Texture
  87303. */
  87304. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  87305. }
  87306. }